#include #include #include #include using namespace std; char tmp_map[18][32]; char map[18][32] = { "###############################", "# #", "# #", "# #", "# ####### #", "# # # #", "# # # #", "# # # #", "# # # #", "# # # #", "# # ########### #", "# # # #", "# ################# #", "# #", "# #", "# #", "# #", "###############################" }; void show_map(short pts) { for(int i = 0; i < 18; i++) { printf("%s\n",map[i] ); } cout << pts << endl; } void gotoxy(short x, short y){ tmp_map=map; tmp_map[x][y]='O' } int main() { int x = 15; int y = 16; int pts = 0; system("cls"); gotoxy( x, y ); while( true ) { show_map(); if ( GetAsyncKeyState( VK_UP ) ) { if( map[y-1][x] == ' ' ) { y--; pts++; } } if ( GetAsyncKeyState( VK_DOWN ) ) { if( map[y+1][x] == ' ' ) { y++; pts++; } } if ( GetAsyncKeyState( VK_LEFT ) ) { if( map[y][x-1] == ' ' ) { x--; pts ++; } } if ( GetAsyncKeyState( VK_RIGHT ) ) { if( map[y][x+1] == ' ' ) { x++; pts++; } } gotoxy( x,y ); Sleep( 100 ); } return 0; }