C++#include <bits/stdc++.h>
#include <conio.h>
using namespace std;
int player_x = 0;
int player_y = 0;
char you_name;
void print_board(){
system("cls");
for (int i = 0; i < 10; i++){
for (int j = 0; j < 10; j++){
if (i == player_x && j == player_y)
cout << you_name;
else
cout << '.';
}
cout << endl;
}
}
void move(int mx, int my){
player_x += mx;
player_y += my;
if (player_x < 0 || player_y < 0 || player_x > 9 || player_y > 9){
player_x -= mx;
player_y -= my;
}
}
int main(){
cout << "WELCOME TO THE PUSH BOX GAME!\n\n";
cout << "Enter a character to represent your appearance on the map:\n";
you_name = getch();
system("cls");
while (1){
print_board();
cout << "Okay, now, enter a character (W/S/A/D) to represent one movement:\n";
char move_to_where = getch();
if (move_to_where == 'W')
move(-1, 0);
if (move_to_where == 'S')
move(1, 0);
if (move_to_where == 'A')
move(0, -1);
if (move_to_where == 'D')
move(0, 1);
}
return 0;
}