Created
May 14, 2012 10:50
-
-
Save anonymous/2693269 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <fstream> | |
| const int ROWS= 10; | |
| const int COLUM= 10; | |
| bool loadmap ( int [] , int [ROWS][COLUM+1]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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