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
|
#include<iostream>
#include<string>
using namespace std;
void playermove ();
void print();
string player = "P";
string board[8][8] =
{
{{"o"},{"o"},{"o"},{"o"},{"o"},{"o"},{"o"},{"o"}},
{{"o"},{"o"},{"o"},{"o"},{"o"},{"o"},{"o"},{"o"}},
{{"o"},{"o"},{"o"},{"o"},{"o"},{"o"},{"o"},{"o"}},
{{"o"},{"o"},{"o"},{"o"},{"o"},{"o"},{"o"},{"o"}},
{{"o"},{"o"},{"o"},{"o"},{"o"},{"o"},{"o"},{"o"}},
{{"o"},{"o"},{"o"},{"o"},{"o"},{"o"},{"o"},{"o"}},
{{"o"},{"o"},{"o"},{"o"},{"o"},{"o"},{"o"},{"o"}},
{{"o"},{"o"},{"o"},{"o"},{"P"},{"o"},{"o"},{"o"}}};
main(){
while(true){
print();
playermove();}
return 0;
}
void print(){
for(int i = 0; i < 8 ; i++){
cout << "\n" << "\t";
for (int u = 0; u < 8 ; u++){
cout << board[i][u];
}}
}
void playermove(){
for(int i = 0; i < 8 ; i++){
for (int u = 0; u < 8 ; u++){
if(board[i][u] == player){
int y = i;
int x = u;
string move = "lllll";
cout << "\n";
cin >> move;
if (move == "up"){
y = y - 1;}
else if (move == "down"){
y = y + 1;}
else if (move == "right"){
x = x + 1;}
else if (move == "left"){
x = x - 1;}
else {cout << "wait what are you trying to do?";}
board[i][u] = "o";
board[y][x] = "P";
};
}}
}
| |