1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#include <iostream>
using namespace std;
int main()
{
// two example maps, these ideally should go in a header
// out the way so that your not cluttering your source.
char map1[21][48] =
{
"###############################################",
"#@ WW#",
"# WWW w WW#",
"# WWWW a WW #",
"# WWW # WW #",
"# # # WW #",
"# T # # WW #",
"# T f #A B# WW #",
"# MM ##D## WW #",
"# MMMM h WW #",
"# T WW #",
"# T T WW #",
"# T T T WW #",
"# T T T T WW #",
"# T TWW T #",
"# p W T TWW #",
"# WWWW T T T WWT #",
"# T WWWW T T WWWWWW #",
"# + W T WWWWWWWWWWWW#",
"# WWWWWWWWWWWWW#",
"###############################################"
};
char map2[21][48] =
{
"###############################################",
"#@ T WW#",
"# TTT WWW w WWWWW WWWW WW#",
"# WWWW a WW #",
"# WWWW WWW # WW #",
"# WWWWW # # WW #",
"# T WW # # WW #",
"# T f W #A B# WW #",
"# MM ##D## WW #",
"# MMMM h WW #",
"# T WW #",
"# T WW T W T WW #",
"# TTT W T T WW #",
"# T T W T T T WW #",
"# WWWW WWWW T TWW T #",
"# p W T TWW #",
"# WWWW T T T WWT #",
"# T WWWW T T WWWWWW #",
"# + W T WWWWWWWWWWWW#",
"# WWWWWWWWWWWWW#",
"###############################################"
};
// playing area map, this is where out map1..map2 lookup
// data is copied to depending on what level we are on.
// nb. try changing currentLevel to 2 and the map will
// change as expected.
char map[21][48]; // playing area
int currentLevel = 1; // what level we are on
// what level are we playing...?
switch (currentLevel)
{
case 1:
memcpy(map, map1, sizeof(map1)); // copy map1 to map
break;
case 2:
memcpy(map, map2, sizeof(map2)); // copy map2 to map
break;
}
// ok show map level
for (int down = 0; down < 21; down++) {
for (int across = 0; across < 48; across++)
cout << map[down][across];
cout << endl;
}
return 0;
}
|