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
|
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int main() {
char grid[10][10] = { { '*','*','*','*','*','*','*','*','*','*',},
{ '*',' ',' ',' ',' ',' ',' ',' ',' ','*',},
{ '*',' ',' ',' ',' ',' ',' ',' ',' ','*',},
{ '*',' ',' ',' ',' ',' ',' ',' ',' ','*',},
{ '*',' ',' ',' ',' ',' ',' ',' ',' ','*',},
{ '*',' ',' ',' ',' ',' ',' ',' ',' ','*',},
{ '*',' ',' ',' ',' ',' ',' ',' ',' ','*',},
{ '*',' ',' ',' ',' ',' ',' ',' ',' ','*',},
{ '*',' ',' ',' ',' ',' ',' ',' ',' ','*',},
{ '*','*','*','*','*','*','*','*','*','*' } };
char player = 'P', trap = 'X', goal = 'G',move;
int x = 1, y = 1;
grid[x][y] = player;
grid[5][4] = trap;
grid[8][8] = goal;
for (int row = 0; row < 10; row++) {
for (int column = 0; column < 10; column++) {
cout << grid[row][column];
}
cout << endl;
}
bool gameon = true;
do{
cout << "move" << endl;
cin >> move;
if (move == 'r') {
grid[x + 1][y] = player;
}
} while (!gameon);
system("pause");
return 0;
}
|