Tuesday, October 4, 2011

Console snake like game in c

#include<conio.h>

#include<stdlib.h>

#include<dos.h>

#define ESC   27

#define TOP   72

#define DOWN  80

#define RIGHT 77

#define LEFT  75

void main()

{

clrscr();

int x=2,y=2;

int x1=77, y1=49;

char a;

textcolor(YELLOW);

while(x<=x1)

{

gotoxy(x,y);

cprintf("*");

x++;

delay(50);

}

while(y<=y1)

{

gotoxy(x1,y);

cprintf("*");

y++;

delay(50);

}

x=2;

while(x1>=x)

{

gotoxy(x1,y1);

cprintf("*");

x1--;

delay(50);

}

y=2;

while(y1>=y)

{

gotoxy(x,y1);

cprintf("*");

y1--;

delay(50);

}

 

/*a=getch();

if(a==27)

exit(0);*/

}

//while(

 

 

No comments :

Post a Comment