Wednesday 6 December 2017

A SIMPLE GAME BY ME



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?
  1. #include <graphics.h>
  2. #include<dos.h>
  3. #include<conio.h>
  4. #include<iostream.h>
  5. #include<stdio.h>
  6. #include <ctype.h>
  7. void main()
  8. {
  9. clrscr();
  10. int gd=DETECT,gm;
  11. initgraph(&gd,&gm,"c:\\turboc3\\bgi");
  12. int x=639,y=479;
  13. char a;int score=0;char abc[1];unsigned int speed=5;
  14. outtextxy(200,200,"HELLO! THIS IS MY FIRST GAME");
  15. outtextxy(170,220,"Press any key to continue....");
  16. getch();
  17. cleardevice();
  18. outtextxy(200,200,"PRESS 'SPACE' TO JUMP");
  19. outtextxy(250,220,"PRESS 'e' TO EXIT");
  20. outtextxy(200,240,"Press any key to continue....");
  21. getch();
  22. for(int i=1;i<=x;i++)
  23. {
  24. cleardevice();
  25. line(0,y,x,y);
  26. circle(80,y-25,25);
  27. line(x-30-i,y,x-30-i,y-60);
  28. line(x-50-i,y,x-50-i,y-60);
  29. line(x-30-i,y-60,x-50-i,y-60);delay(speed);
  30. if(i==484)
  31. {
  32. sound(500);
  33. delay(500);
  34. nosound();
  35. window(35,15,40,25);
  36. outtextxy(300,200,"GAME OVER");
  37. printf("Your Score is %d",score);
  38. outtextxy(200,260,"Press any key to exit....");
  39. getch();
  40. break;
  41. }
  42. else if(i<480&&i>350)
  43. {
  44. if(kbhit())
  45. {
  46. a=getch();
  47. int b=a;
  48. if(b==32)
  49. {
  50. cleardevice();
  51. for(int j=1;j<=100;j++)
  52. {
  53. cleardevice();
  54. line(0,y,x,y);
  55. circle(80,y-25-j,25);
  56. line(170-j,y,170-j,y-60);
  57. line(150-j,y,150-j,y-60);
  58. line(170-j,y-60,150-j,y-60);delay(speed);
  59. if(j==100)
  60. {
  61. for(int k=1;k<=100;k++)
  62. {
  63. cleardevice();
  64. line(0,y,x,y);
  65. circle(80,y-125+k,25);delay(speed);
  66. if(k==100)
  67. {
  68. break;
  69. }
  70. }
  71. }
  72. }
  73. ++score;--speed;
  74. }
  75. else if(a=='e')
  76. {
  77. window(35,15,40,25);
  78. outtextxy(200,200,"THANK YOU FOR PLAYING THE GAME");
  79. printf("Your Score is %d",score);
  80. outtextxy(200,260,"Press any key to exit....");
  81. getch();
  82. break;
  83. }

  84. else
  85. {
  86. continue;
  87. }
  88. i=1;
  89. continue;
  90. }
  91. }
  92. else if(kbhit())
  93. {
  94. a=getch();
  95. int b;
  96. if(b==32)
  97. {
  98. for(int j=1;j<=100;j++,i++)
  99. {
  100. cleardevice();
  101. line(0,y,x,y);
  102. circle(80,y-25-j,25);
  103. line(x-30-i,y,x-30-i,y-60);
  104. line(x-50-i,y,x-50-i,y-60);
  105. line(x-30-i,y-60,x-50-i,y-60);delay(speed);
  106. if(j==100)
  107. {
  108. for(int k=1;k<=100;k++,i++)
  109. {
  110. cleardevice();
  111. line(0,y,x,y);
  112. circle(80,y-125+k,25);
  113. line(x-30-i,y,x-30-i,y-60);
  114. line(x-50-i,y,x-50-i,y-60);
  115. line(x-30-i,y-60,x-50-i,y-60);delay(speed);

  116. if(k==100)
  117. {
  118. break;
  119. }
  120. }
  121. }

  122. }
  123. }
  124. }
  125. }
  126. }
If you have any doubts and queries comment below. 




No comments:

Post a Comment