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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
#include<iostream.h>
#include<graphics.h>
#include<iomanip.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
void main()
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "//bgi");
clock_t start,end,r;
int x,y,i,x1,y1,j,l,m,temp,tail,col,scr,scr1,tempo;
char scrn[10];
// char key=0;
temp=30;tail=3;
scr1=0;
int a[300],b[300];
i=y=x=0;
const char up='w';
const char dw='s';
const char ls='a';
const char rs='d';
cout<<" RULES FOR THE GAME"<<endl;
cout<<"KEYS---"<<endl<<" w- FORWARD"<<endl<<" a- LEFT TURN"<<endl<<" d- RIGHT TURN"<<endl<<" s- DOWN"<<endl;
cout<<" Q- QUIT"<<endl;
cout<<" TURN CAPS LOCK OFF"<<endl;
cout<<" EAT THE INSECTS N LIVE...U DIE IF U CROSS THE LIMIT / MOVE OVER UR SELF /"<<endl;
cout<<" CROSS UR LEFTOVER SKIN."<<endl;
cout<<" SHEADS SKIN AFTER REGULAR INTERVALS.."<<endl;
cout<<" KEEP MOVING TO FIND FOOD ELSE U DIE"<<endl;
cout<<" POINTS ARE ADDED FOR EVERY INSECT YOU EAT,BUT EAT THE FIRST ONE BEFORE SECOND ONE COMES UP ELSE NO SCORE WILL BE ADDED UP"<<endl<<endl;
cout<<" PRESS MOVE(a) KEY TO CONTINUE.....";
getch();
cleardevice();
setbkcolor(9);
for(j=0;j<=7;j++)
a[j]=b[j]=0;
rectangle(20,21,600,441);
outtextxy(20,5,"SCORE..");
randomize();
l=(random(520)+60);
if(l<=99)
{l=l/10;
l=l*10;}
else {l=l/10;
l=l*10; }
m=(random(400)+40);
if(m<=99)
{m=m/10;
m=m*10; }
else {m=m/10;
m=m*10; }
outtextxy(l,m,"*");
char key;
do
{
setcolor(15);
rectangle(20,21,600,440);
if(i==60||i==120||i==190||i==270)
{
l=(random(520)+50);
if(l<=99)
{l=l/10;
l=l*10;}
else {l=l/10;
l=l*10; }
m=(random(400)+30);
if(m<=99)
{m=m/10;
m=m*10; }
else {m=m/10;
m=m*10; }
setcolor(15);
outtextxy(l,m,"ì");
sound(3800);
}
start=clock();
key=getch();
end=clock();
r=end-start;
if(r>=15)
{ outtextxy(100,100,"YOU ARE TOO SLOW...:-( ");
delay(1000);nosound();break;}
if (i==300 )
{ i=0;}
{
if(key==up)
{ y-=10;}
if(key==dw)
{ y+=10;}
if(key==ls)
{ x-=10;}
if(key==rs)
{ x+=10;}
}
setcolor(10);
a[i]= x1=210+x;
b[i]= y1=210+y;
if(x1==l && y1==m)
{ scr1++;
scr=10*scr1;
sprintf(scrn,"%d",scr);
nosound();
setcolor(0);
outtextxy(70,5,"ÛÛ");
setcolor(15);
outtextxy(70,5,scrn);
temp+=10;tail++; }
if(x1==20||x1==600||y1==20||y1==440)
{nosound();break;}
col=getpixel(x1,y1);
if(col>0)
break;
nosound();
tempo=tail;
if(i>=(299-tempo))
{ setcolor(4);
tempo-- ;
}
outtextxy(x1,y1,"X");
setcolor(0);
outtextxy(a[i-tail],b[i-tail],"X" );
i++;
} while (key !='q');
settextstyle(2,0,26);
outtextxy(210,210,"OUT");
getch();
closegraph();
}
|