Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "gfx.h"
  4. #include <time.h>
  5. #include <unistd.h>
  6.  
  7. void ready_up ();
  8. void frame ();
  9.  
  10. int main (void)
  11. {
  12. int ysize = 768;
  13. int xsize = 1366;
  14. int a = 1;
  15. int x1 = 100;
  16. int x2 = 100;
  17. int width = 250;
  18. int height = 250;
  19. int loop1;
  20. int score = 0;
  21. char c,x;
  22. char *intro = "Wanna play a game?";
  23. char *start = "Press y to start";
  24. char *red = "Red";
  25. char *green = "Green";
  26. char *purple = "Purple";
  27. char *wrong = "wrong answer";
  28. char *correct = "Correct answer";
  29. char *memorise = "Please memorise the sequence";
  30. char *ready = "If ready press Y";
  31. char *bye = "Bye bye and thank you";
  32. char *score0 = "Your score is zero";
  33. char *score1 = "Your score is one";
  34. char *score2 = "Your score is two";
  35. char *score3 = "Your score is three";
  36. srand(time(NULL));
  37.  
  38. gfx_open (xsize, ysize, "Final Project");
  39. gfx_color (255,255,255);
  40. gfx_text (intro,500,50);
  41. gfx_color (255,255,255);
  42. gfx_text (start,500,75);
  43.  
  44. while (a = 1)
  45. {
  46. x=gfx_wait();
  47. if (x == 'y') {
  48. //red
  49. ready_up ();
  50. x=gfx_wait();
  51. if (x == 'y')
  52. {
  53. gfx_clear();
  54. gfx_color (255,255,255);
  55. gfx_text (red,500,50);
  56. frame ();
  57. x=gfx_wait();
  58. if ((gfx_xpos()>100 && gfx_xpos()<350) && (gfx_ypos()>100 && gfx_ypos()<350))
  59. {
  60. score = score + 1;
  61. gfx_color (255,0,0);
  62. gfx_fillrectangle (100,100,250,250);
  63. x=gfx_wait();
  64. gfx_clear();
  65. gfx_color (255,255,255);
  66. gfx_text (correct,500,50);
  67. if (score == 0)
  68. gfx_text (score0,500,75);
  69. if (score==1)
  70. gfx_text (score1,500,75);
  71. if (score==2)
  72. gfx_text (score2,500,75);
  73. if (score==3)
  74. gfx_text (score3,500,75);
  75. x=gfx_wait ();
  76. //break;
  77. }
  78. else
  79. {
  80. gfx_clear ();
  81. gfx_text (wrong,500,50);
  82. if (score == 0)
  83. gfx_text (score0,500,75);
  84. if (score==1)
  85. gfx_text (score1,500,75);
  86. if (score==2)
  87. gfx_text (score2,500,75);
  88. if (score==3)
  89. gfx_text (score3,500,75);
  90. x=gfx_wait ();
  91. //break;
  92. }
  93. //green
  94. ready_up ();
  95. x=gfx_wait();
  96. if (x == 'y') gfx_clear();
  97. gfx_color (255,255,255);
  98. gfx_text (green,500,50);
  99. frame ();
  100. x=gfx_wait();
  101. if ((gfx_xpos()>850 && gfx_xpos()<1100) && (gfx_ypos()>350 && gfx_ypos()<600))
  102. {
  103. score = score + 1;
  104. gfx_color (134,255,67);
  105. gfx_fillrectangle (850,350,250,250);
  106. x=gfx_wait();
  107. gfx_clear();
  108. gfx_color (255,255,255);
  109. gfx_text (correct,500,50);
  110. if (score == 0)
  111. gfx_text (score0,500,75);
  112. if (score==1)
  113. gfx_text (score1,500,75);
  114. if (score==2)
  115. gfx_text (score2,500,75);
  116. if (score==3)
  117. gfx_text (score3,500,75);;
  118. x=gfx_wait ();
  119. }
  120. else
  121. {
  122. gfx_clear ();
  123. gfx_text (wrong,500,50);
  124. if (score == 0)
  125. gfx_text (score0,500,75);
  126. if (score==1)
  127. gfx_text (score1,500,75);
  128. if (score==2)
  129. gfx_text (score2,500,75);
  130. if (score==3)
  131. gfx_text (score3,500,75);
  132. x=gfx_wait ();
  133. //break;
  134. }
  135. //purple
  136. ready_up ();
  137. x=gfx_wait();
  138. if (x == 'y') gfx_clear();
  139. gfx_color (255,255,255);
  140. gfx_text (purple,500,50);
  141. frame ();
  142. x=gfx_wait();
  143. if ((gfx_xpos()>600 && gfx_xpos()<850) && (gfx_ypos()>100 && gfx_ypos()<350))
  144. {
  145. score = score + 1;
  146. gfx_color (134,56,125);
  147. gfx_fillrectangle (600,100,250,250);
  148. x=gfx_wait();
  149. gfx_clear();
  150. gfx_color (255,255,255);
  151. gfx_text (correct,500,50);
  152. if (score == 0)
  153. gfx_text (score0,500,75);
  154. if (score==1)
  155. gfx_text (score1,500,75);
  156. if (score==2)
  157. gfx_text (score2,500,75);
  158. if (score==3)
  159. gfx_text (score3,500,75);
  160. x=gfx_wait ();
  161. //break;
  162. }
  163. else
  164. {
  165. gfx_clear ();
  166. gfx_text (wrong,500,50);
  167. if (score == 0)
  168. gfx_text (score0,500,75);
  169. if (score==1)
  170. gfx_text (score1,500,75);
  171. if (score==2)
  172. gfx_text (score2,500,75);
  173. if (score==3)
  174. gfx_text (score3,500,75);
  175. x=gfx_wait ();
  176. //break;
  177. }
  178. //level1.1
  179. //level1.2
  180. //level1.3
  181. } //if x == 'y'
  182. else
  183. {
  184. gfx_clear ();
  185. gfx_color(255,255,255);
  186. gfx_text(bye,600,300);
  187. if (score == 0)
  188. gfx_text (score0,550,250);
  189. if (score==1)
  190. gfx_text (score1,550,250);
  191. if (score==2)
  192. gfx_text (score2,550,250);
  193. if (score==3)
  194. gfx_text (score3,550,250);
  195. x=gfx_wait ();
  196. break;
  197. }
  198. gfx_clear ();
  199. gfx_color(255,255,255);
  200. gfx_text(bye,600,300);
  201. if (score == 0)
  202. gfx_text (score0,550,250);
  203. if (score==1)
  204. gfx_text (score1,550,250);
  205. if (score==2)
  206. gfx_text (score2,550,250);
  207. if (score==3)
  208. gfx_text (score3,550,250);
  209. x=gfx_wait ();
  210. break;
  211. if (x == 'u') break;
  212. } //if
  213. } //while
  214. } //main
  215.  
  216. void ready_up ()
  217. {
  218. char *memorise = "Please memorise the sequence";
  219. char *ready = "If ready press Y";
  220. gfx_clear();
  221. gfx_color (255,0,0);
  222. gfx_fillrectangle (100,100,250,250);
  223. gfx_color (134,0,0);
  224. gfx_fillrectangle (350,100,250,250);
  225. gfx_color (134,56,125);
  226. gfx_fillrectangle (600,100,250,250);
  227. gfx_color (156,89,87);
  228. gfx_fillrectangle (850,100,250,250);
  229. gfx_color (134,189,56);
  230. gfx_fillrectangle (1100,100,250,250);
  231. gfx_color (23,67,89);
  232. gfx_fillrectangle (100,350,250,250);
  233. gfx_color (89,0,255);
  234. gfx_fillrectangle (350,350,250,250);
  235. gfx_color (123,90,56);
  236. gfx_fillrectangle (600,350,250,250);
  237. gfx_color (134,255,67);
  238. gfx_fillrectangle (850,350,250,250);
  239. gfx_color (45,255,255);
  240. gfx_fillrectangle (1100,350,250,250);
  241.  
  242. gfx_color (255,255,255);
  243. gfx_text (memorise,500,50);
  244. gfx_text (ready, 500,75);
  245. }
  246.  
  247. void frame ()
  248. {
  249. int loop1;
  250. int x1 = 100;
  251. int x2 = 100;
  252.  
  253. for (loop1=0; loop1<5; loop1++)
  254. {
  255. gfx_rectangle (x1,100,249,249);
  256. x1=x1+250;
  257. }
  258. for (loop1=0; loop1<5; loop1++)
  259. {
  260. gfx_rectangle (x2,350,249,249);
  261. x2=x2+250;
  262. }
  263. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement