A SIMPLE GAME BY ME
Do you remember this game?
Don't expect too much. In the place of T-REX there is a BALL and
obstacles are BLOCKS.I tried a little. Here is my GAMEPLAY
MY GAMEPLAY.
Eager to see the code.Totally 129 lines. R U READY?
- #include <graphics.h>
- #include<dos.h>
- #include<conio.h>
- #include<iostream.h>
- #include<stdio.h>
- #include <ctype.h>
- void main()
- {
- clrscr();
- int gd=DETECT,gm;
- initgraph(&gd,&gm,"c:\\turboc3\\bgi");
- int x=639,y=479;
- char a;int score=0;char abc[1];unsigned int speed=5;
- outtextxy(200,200,"HELLO! THIS IS MY FIRST GAME");
- outtextxy(170,220,"Press any key to continue....");
- getch();
- cleardevice();
- outtextxy(200,200,"PRESS 'SPACE' TO JUMP");
- outtextxy(250,220,"PRESS 'e' TO EXIT");
- outtextxy(200,240,"Press any key to continue....");
- getch();
- for(int i=1;i<=x;i++)
- {
- cleardevice();
- line(0,y,x,y);
- circle(80,y-25,25);
- line(x-30-i,y,x-30-i,y-60);
- line(x-50-i,y,x-50-i,y-60);
- line(x-30-i,y-60,x-50-i,y-60);delay(speed);
- if(i==484)
- {
- sound(500);
- delay(500);
- nosound();
- window(35,15,40,25);
- outtextxy(300,200,"GAME OVER");
- printf("Your Score is %d",score);
- outtextxy(200,260,"Press any key to exit....");
- getch();
- break;
- }
- else if(i<480&&i>350)
- {
- if(kbhit())
- {
- a=getch();
- int b=a;
- if(b==32)
- {
- cleardevice();
- for(int j=1;j<=100;j++)
- {
- cleardevice();
- line(0,y,x,y);
- circle(80,y-25-j,25);
- line(170-j,y,170-j,y-60);
- line(150-j,y,150-j,y-60);
- line(170-j,y-60,150-j,y-60);delay(speed);
- if(j==100)
- {
- for(int k=1;k<=100;k++)
- {
- cleardevice();
- line(0,y,x,y);
- circle(80,y-125+k,25);delay(speed);
- if(k==100)
- {
- break;
- }
- }
- }
- }
- ++score;--speed;
- }
- else if(a=='e')
- {
- window(35,15,40,25);
- outtextxy(200,200,"THANK YOU FOR PLAYING THE GAME");
- printf("Your Score is %d",score);
- outtextxy(200,260,"Press any key to exit....");
- getch();
- break;
- }
- else
- {
- continue;
- }
- i=1;
- continue;
- }
- }
- else if(kbhit())
- {
- a=getch();
- int b;
- if(b==32)
- {
- for(int j=1;j<=100;j++,i++)
- {
- cleardevice();
- line(0,y,x,y);
- circle(80,y-25-j,25);
- line(x-30-i,y,x-30-i,y-60);
- line(x-50-i,y,x-50-i,y-60);
- line(x-30-i,y-60,x-50-i,y-60);delay(speed);
- if(j==100)
- {
- for(int k=1;k<=100;k++,i++)
- {
- cleardevice();
- line(0,y,x,y);
- circle(80,y-125+k,25);
- line(x-30-i,y,x-30-i,y-60);
- line(x-50-i,y,x-50-i,y-60);
- line(x-30-i,y-60,x-50-i,y-60);delay(speed);
- if(k==100)
- {
- break;
- }
- }
- }
- }
- }
- }
- }
- }
No comments:
Post a Comment