lihat program ini dan run...selanjutnya mainkan...nikmatilah kawan..^^
* Tembak-tembak-an
by:
Afrisal Yodi Purnama
2208100128
Teknik Elektro ITS
*/
#include
#include
#include
#include
int int_x=35,move,n,x,poin=0,bebek=0;
char navigasi;
void petunjuk();
void awal();
void game();
void main()
{
awal();
}
void game()
{
clrscr();
gotoxy(35,40);printf("=*=");
int_x=35;
gotoxy(65,1);printf("Press k to exit");
poin=0;
bebek=0;
do
{
for(x=1;x<=75;x++)
{
delay(70);
gotoxy(x-1,2);printf(" ");
gotoxy(x,2);printf("s");
if(kbhit())
{
navigasi=getch();
switch(navigasi)
{
case 'd':if(int_x<=73){int_x=int_x+1;move=1;}break;
case 'a':if(int_x>=3){int_x=int_x-1;move=1;}break;
case 'k':x=76;navigasi='k';break;
case ' ':
for(n=39;n>0;n--)
{
x++;
gotoxy(x-1,2);printf(" ");
gotoxy(x,2);printf("s");
gotoxy(int_x+1,n);printf("|");
gotoxy(int_x+1,n+1);printf(" ");
gotoxy(int_x+1,40);printf("*");
delay(70);
if(x==75){x=1;bebek++;gotoxy(75,2);printf(" ");}
if((x==int_x+1)&&(n==2))
{
poin++;
gotoxy(x,n);printf("@");
delay(500);
x=1;
}
}
gotoxy(int_x+1,1);printf(" ");
gotoxy(65,1);printf("Press k to exit");
break;
default:move=0;break;
}
}
gotoxy(1,1);printf("Poin : %d",poin);
gotoxy(1,3);printf(" ");
gotoxy(15,41);printf(" ");
gotoxy(1,41);printf("Sisa bebek : %d",30-bebek);
if(x==75){gotoxy(75,2);printf(" ");}
if(move==1)
{
gotoxy(int_x-1,40);printf(" ");
gotoxy(int_x+3,40);printf(" ");
gotoxy(int_x,40);printf("=*=");
}
}
if(bebek<=30)
bebek++;
if(bebek>30)
{
gotoxy(25,25);printf("Poin yang anda dapatkan : %d",poin);
getch();
awal();
}
}while (navigasi!='k');
awal();
}
void awal()
{
int a;
clrscr();
printf("MAIN MENU\n");
printf("1. New Game\n");
printf("2. Petunjuk Permainan\n");
printf("3. Exit");
a=getch();
switch(a)
{
case '1': game();break;
case '2': petunjuk();break;
case '3': exit(1);break;
default : printf("\nPilih angka 1-4!");getch();break;
}
}
void petunjuk()
{
clrscr();
printf(" Petunjuk Permainan\n");
printf("Tembaklah bebek yang dilambangkan\n");
printf("dengan huruf 's'sedemikian hingga\n");
printf("peluru mengenai bebek tersebut.\n");
printf("Terdapat 30 bebek yang melewati me-\n");
printf("dan tembak. Yang mampu menembak be-\n");
printf("bek dengan tepat dengan poin terbanyak\n");
printf("Dialah yang menjadi pemenang.\n");
printf("\nkeyboard controler:\n");
printf("kanan : d\n");
printf("kiri : a\n");
printf("Tembak : space\n");
printf("\n\nPress any key...");
getch();
awal();
}
Tidak ada komentar:
Posting Komentar