nah ini nih kode programnya
#include
#include
void main()
{
clrscr();
int x,y;
x=40;
y=12;
randomize();
int x1,y1;
x1=random(78)+1;
y1=random(24)+1;
long skor;
skor=0;
int tombol;
do
{
clrscr();
gotoxy(x1,y1);
cprintf("$");
gotoxy(1,5);
cout<<"Skor : "<
cprintf("*");
tombol=getch();
if(tombol==0)
{
tombol=getch();
if(tombol==72)
{
if(y>1)
y=y-1;
else
y=24;
}
else if(tombol==80)
{
if(y<24)
y=y+1;
else
y=1;
}
else if(tombol==75)
{
if(x>1)
x=x-1;
else
x=79;
}
else if(tombol==77)
{
if(x<79)
x=x+1;
else
x=1;
}
}
if(x==x1 && y==y1)
{
skor=skor+10;
x1=random(78)+1;
y1=random(24)+1;
}
}while(tombol!=27);
}
Game Snack Versi 2 silahkan Tik
#include
#include
#include
void main()
{
clrscr();
int x,y;
x=40;
y=12;
randomize();
int x1,y1;
int ax,ay;
ax=0;
ay=0;
x1=random(78)+1;
y1=random(24)+1;
long skor;
skor=0;
int tombol;
do
{
clrscr();
gotoxy(x1,y1);
cprintf("$");
gotoxy(1,5);
cout<<"Skor : "<
cprintf("*");
delay(100);
if(kbhit())
{
tombol=getch();
if(tombol==0)
{
tombol=getch();
if(tombol==72)
{
ax=0;
ay=-1;
}
else if(tombol==80)
{
ax=0;
ay=1;
}
else if(tombol==75)
{
ax=-1;
ay=0;
}
else if(tombol==77)
{
ax=1;
ay=0;
}
}
}
x=x+ax;
y=y+ay;
if(x==78)
x=1;
else if(x==1)
x=78;
if(y==1)
y=24;
else if(y==24)
y=1;
if(x==x1 && y==y1)
{
skor=skor+10;
x1=random(78)+1;
y1=random(24)+1;
}
}while(tombol!=27);
}
1 komentar:
hapunten gan,,
ni programnya ko gada yang jadi ya.
tolong di cek ulang kawan..
buat ane ang newbie gini butuh gan...
terimakasih sebalumnya...
Posting Komentar