Skip to content

Instantly share code, notes, and snippets.

Created May 14, 2012 10:50
Show Gist options
  • Select an option

  • Save anonymous/2693269 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/2693269 to your computer and use it in GitHub Desktop.
#include "function.h"
#include <fstream>
using namespace std;
bool loadmap ( int startpos[] , int gamemap[ROWS][COLUM+1])
{
ifstream ins;
ins.open("map.txt");
if(ins.fail())
return false;
else
{
ins >> startpos[0] >> startpos[1];
for( int i = 0; i < ROWS; i++)
{ for ( int j= 0; j < COLUM; j++);
ins >> gamemap[i][j];
}
// load map.txt into array
}
return 0;
}
#include <fstream>
const int ROWS= 10;
const int COLUM= 10;
bool loadmap ( int [] , int [ROWS][COLUM+1]);
#include <iostream>
#include "function.h"
using namespace std;
int main ()
{
int startpos[2];
int gamemap[ROWS][COLUM+1]= {{0}};
if(loadmap( startpos,gamemap))
{
// play the game
}
else
{
for ( int i= 0; i < 11; i++)
{ for( int j= 0; j < 11; j++)
cout << gamemap[i][j];
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment