Вы находитесь на странице: 1из 3

#include<stdio.

h>
#include<conio.h>
#include<windows.h>
#include<string.h>
#include<stdlib.h>
void gotoxy(int x,int y)
{
COORD a;
a.X=x;
a.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),a);
}
class point
{
private:
int x;
int y;
public:
point()
{
x=1;
y=1;
}
void display()
{
printf("%c",177);
}
void move_right()
{
if()
{
system("cls");
x++;
gotoxy(x,y);
display();
Sleep(500);
}
else
{
printf("GAME OVER");
}
}
void move_left()
{
if(x>1)
{
system("cls");
x--;
gotoxy(x,y);
display();
Sleep(500);
}
}

void move_up()
{
if(y>1)
{
system("cls");
y--;
gotoxy(x,y);
display();
Sleep(500);
}
}
void move_down()
{
if(y<=50)
{
system("cls");
y++;
gotoxy(x,y);
display();
Sleep(500);
}
}
void game_box()
{
int i;
for(i=0;i<50;i++)
{
printf("\xDB");
}
gotoxy(0,0);
for(i=0;i<=20;i++)
{
printf("\xDB\n");
}
gotoxy(0,20);
for(i=0;i<50;i++)
{
printf("\xDB");
}
gotoxy(50,0);
for(i=0;i<=20;i++)
{
gotoxy(50,0+i);
printf("\xDB\n");
}
}
};
void main()
{
class point l;
char ch='d';
l.game_box();
gotoxy(1,1);
l.display();

/*while(1)
{
if(kbhit())
{
ch=getch();
if(ch=='a')
{
l.move_left();
}
else if(ch=='d')
{
l.move_right();
}
else if(ch=='w')
{
l.move_up();
}
else if(ch=='s')
{
l.move_down();
}
}
else
{
if(ch=='a')
{
l.move_left();
}
else if(ch=='d')
{
l.move_right();
}
else if(ch=='w')
{
l.move_up();
}
else if(ch=='s')
{
l.move_down();
}
}
}*/
getch();
}

Вам также может понравиться