#include #include #include #include using namespace std; int running=0; int initvar=0; int dir=2; int xpos = 39, ypos = 13; int oldxpos, oldypos; int draw=1; int lives=3; void sleep(unsigned int mseconds) { clock_t goal = mseconds + clock(); while (goal > clock()); } void gotoxy(int x, int y) { HANDLE hConsoleOutput; COORD dwCursorPosition; dwCursorPosition.X = x; dwCursorPosition.Y = y; hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition); } void init() { for (int i=0; i < 80; i++) { for (int j=0; j < 25; j++) { gotoxy(i,j); cout<<" "; } } } void draw_status() { for (int i=0; i < 80; i++) { gotoxy(i,1); cout<<"-"; } } int main() { if (initvar==0) { init(); initvar=1; draw_status(); } while(running != 1) { if (_kbhit()) { int ch = getch(); oldxpos = xpos; oldypos = ypos; switch(ch) { case 27 : { running = 1; break; } case 72 : { if (ypos > 3) ypos--; dir=8; draw = 1; break; } case 75 : { if (xpos > 1) xpos--; dir=4; draw = 1; break; } case 77 : { if (xpos < 78) xpos++; dir=6; draw = 1; break; } case 80 : { if (ypos < 23) ypos++; dir=2; draw = 1; break; } case 224 : { break; //do nothing } default : { //cout<