1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
void Snake::Play()
{
char Arrow_Key, Dummy;
Init_Points();
Create_Rect(Start);
Generate_Food();
settextstyle(0, 0, 1);
HighScore(IN);
while(!Dead)
{
outtextxy( (getmaxx() / 2) - 55, (getmaxy() / 2) - 5, "High Score: ");
outtextxy( (getmaxx() / 2) + 55, (getmaxy() / 2) - 5, HighScore_String);
outtextxy( (getmaxx() / 2) - 55, (getmaxy() / 2) + 5, " Score: ");
outtextxy( (getmaxx() / 2) + 55, (getmaxy() / 2) + 5, Score_String);
setfillstyle(1, RED);
rectangle(Food_LX, Food_LY, Food_RX, Food_RY);
floodfill(Food_LX + 5, Food_LY + 5, RED);
Create_Rect(Start);
if(kbhit())
{
Arrow_Key = getch();
if(Arrow_Key != 0)
{
Arrow_Key = 0;
New_Key = Old_Key;
}
else
{
New_Key = getch();
}
}
if(Arrow_Key == 0)
{
Move(Start, New_Key);
delay(50);
Collision();
if(Dead)
{
while(kbhit())
{
Dummy = getch();
if(Dummy == 0)
{
Dummy = getch();
}
}
}
cleardevice();
}
}
}
|