nelltbe

Project.c 2.0 zaid

Nov 19th, 2019
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.12 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "gfx.h"
  3. #include <stdlib.h>
  4. #include <time.h>
  5.  
  6. int score_add(int score1);
  7. int score_minus(int score1);
  8. int guess_add(int guess1);
  9. int guess_minus(int guess1);
  10.  
  11. int main()
  12.  
  13. { //146
  14. char c;
  15. char *test = "Would you like to play a game? Y/N" ;
  16.  
  17. char *levelone = "LEVEL 1-1";
  18. char *leveltwo = "LEVEL 1-2";
  19. char *levelthree = "LEVEL 1-3";
  20. char *levelfour = "LEVEL 1-4";
  21. char *levelfive = "LEVEL 1-5";
  22.  
  23. char *between = "Left click the mouse to continue";
  24.  
  25. char *red = "RED";
  26. char *lblue = "LIGHT BLUE";
  27. char *dblue = "DARK BLUE";
  28. char *yellow = "YELLOW";
  29. char *dgreen = "DARK GREEN";
  30. char *lgreen = "LIGHT GREEN";
  31. char *brown = "BROWN";
  32. char *purple ="PURPLE";
  33. char *pink = "PINK";
  34. char *black = "BLACK";
  35.  
  36. char *correct = "CORRECT";
  37. char *wrong = "WRONG";
  38.  
  39. char *guessone = "You have 1 guesses left";
  40. char *guesstwo = "You have 2 guesses left";
  41. char *guessthree = "You have 3 guesses left";
  42.  
  43. char *scorezero = "SCORE = 0";
  44. char *scoreone = "SCORE = 1";
  45. char *scoretwo = "SCORE = 2";
  46. char *scorethree = "SCORE = 3";
  47. char *scorefour = "SCORE = 4";
  48. char *scorefive = "SCORE = 5";
  49.  
  50. char *end = "Okay, Please come again!";
  51. char *end1 = "Press any key to exit";
  52.  
  53. int x,y,score,guess;
  54. char n;
  55.  
  56. guess = 3;
  57. score = 0;
  58.  
  59. gfx_open(3000,1000,"bew");
  60. gfx_clear_color(255,255,255);
  61. gfx_clear();
  62.  
  63. gfx_color(0,0,0);
  64. gfx_text(test,800,500);
  65.  
  66. while (1) {//143
  67.  
  68. c = gfx_wait();
  69. x = gfx_xpos();
  70. y = gfx_ypos();
  71.  
  72. if (c==0x01)
  73. {
  74. }
  75. /* else
  76. {
  77. printf("%c \n",c);
  78. printf("Mouse pos xpos is %d and ypos is %d \n", gfx_xpos(),gfx_ypos());
  79. }
  80.  
  81. if ((x >= 200 && x <= 400) && (y >= 100 && y <= 300))
  82. {//123
  83. printf("Correct \n");
  84. //gfx_color(255,255,0);
  85. //gfx_fillcircle(50,500,100);
  86. }//121*/
  87.  
  88. //c = gfx_wait();
  89.  
  90. if ((c =='Y') || (c == 'y'))
  91. //level one(91 - 183)
  92. {//165
  93. gfx_clear();
  94. gfx_text(levelone,1100,100);
  95. gfx_text(red,100,100);
  96. gfx_text(scorezero,100,200);
  97. gfx_text(guessthree,100,300);
  98.  
  99. // setting line color
  100. gfx_color(0,0,0);
  101.  
  102. //drawing vertical grid
  103. gfx_line(600,0,600,1000);
  104. gfx_line(800,0,800,1000);
  105. gfx_line(1000,0,1000,1000);
  106.  
  107. //drawing horizontal grid
  108. gfx_line(600,200,1000,200);
  109. gfx_line(600,400,1000,400);
  110. gfx_line(600,600,1000,600);
  111. gfx_line(600,800,1000,800);
  112. gfx_line(600,1000,1000,1000);
  113.  
  114. // drawing in circles with different colors
  115.  
  116. gfx_color(0,0,0); //black
  117. gfx_fillcircle(700,100,150);
  118.  
  119. gfx_color(255,0,0); //red
  120. gfx_fillcircle(900,100,150);
  121.  
  122. gfx_color(0,255,0); //light green
  123. gfx_fillcircle(700,300,150);
  124.  
  125. gfx_color(0,0,255); //light blue
  126. gfx_fillcircle(900,300,150);
  127.  
  128. gfx_color(255,255,0); //yellow
  129. gfx_fillcircle(700,500,150);
  130.  
  131. gfx_color(0,128,0); //dark green
  132. gfx_fillcircle(900,500,150);
  133.  
  134. gfx_color(255,0,255); //pink
  135. gfx_fillcircle(700,700,150);
  136.  
  137. gfx_color(128,0,128); //purple
  138. gfx_fillcircle(900,700,150);
  139.  
  140. gfx_color(0,0,100); //dark blue
  141. gfx_fillcircle(700,900,150);
  142.  
  143. gfx_color(65,42,42); //brown
  144. gfx_fillcircle(900,900,150);
  145.  
  146. x = gfx_wait();
  147.  
  148. if ((x >= 800 && x <= 1000) || (y >= 0 && y <= 200)) // correct decision
  149. {//140
  150. gfx_clear();
  151. gfx_text(correct,800,300);
  152. score = score_add(score);
  153. gfx_text(scoreone,800,400);
  154. gfx_text(guessthree,800,450);
  155. gfx_text(between,800,500);
  156. printf("%d\n",score);
  157. c = gfx_wait();
  158. gfx_clear();
  159. }//136
  160.  
  161. else // wrong decision
  162. {//163
  163. gfx_clear();
  164. gfx_text(wrong,800,300);
  165. guess = guess_minus(guess);
  166. gfx_text(scorezero,800,400);
  167. gfx_text(guesstwo,800,450);
  168. gfx_text(between,800,500);
  169. printf("%d\n",guess);
  170. c = gfx_wait();
  171. gfx_clear();
  172. }//155
  173.  
  174. if (score == 1)
  175. {
  176. gfx_text(guessthree,100,250);
  177. gfx_text(scoreone,100,200);
  178. }
  179. if (guess == 2)
  180. {
  181. gfx_text(guesstwo,100,250);
  182. gfx_text(scorezero,100,200);
  183. }
  184.  
  185. //level two(186 - 295)
  186. gfx_text(leveltwo,1100,100);
  187. gfx_text(lblue,100,100);
  188.  
  189. // setting line color
  190. gfx_color(0,0,0);
  191.  
  192. //drawing vertical grid
  193. gfx_line(600,0,600,1000);
  194. gfx_line(800,0,800,1000);
  195. gfx_line(1000,0,1000,1000);
  196.  
  197. //drawing horizontal grid
  198. gfx_line(600,200,1000,200);
  199. gfx_line(600,400,1000,400);
  200. gfx_line(600,600,1000,600);
  201. gfx_line(600,800,1000,800);
  202. gfx_line(600,1000,1000,1000);
  203.  
  204. // drawing in circles with different colors
  205.  
  206. gfx_color(255,0,255); //pink
  207. gfx_fillcircle(700,100,150);
  208.  
  209. gfx_color(255,255,0); //yellow
  210. gfx_fillcircle(900,100,150);
  211.  
  212. gfx_color(255,0,0); //red
  213. gfx_fillcircle(700,300,150);
  214.  
  215. gfx_color(0,0,100); //dark blue
  216. gfx_fillcircle(900,300,150);
  217.  
  218. gfx_color(65,42,42); //brown
  219. gfx_fillcircle(700,500,150);
  220.  
  221. gfx_color(0,128,0); //dark green
  222. gfx_fillcircle(900,500,150);
  223.  
  224. gfx_color(0,0,0); //black
  225. gfx_fillcircle(700,700,150);
  226.  
  227. gfx_color(0,255,0); //light green
  228. gfx_fillcircle(900,700,150);
  229.  
  230. gfx_color(0,0,255); //light blue
  231. gfx_fillcircle(700,900,150);
  232.  
  233. gfx_color(128,0,128); //purple
  234. gfx_fillcircle(900,900,150);
  235.  
  236. x = gfx_wait();
  237. gfx_color(0,0,0);
  238.  
  239. if ((x >= 600 && x <= 800) || (y >= 800 && y <= 1000)) // correct condition
  240. {
  241. if (score == 1)
  242. {//140
  243. gfx_clear();
  244. gfx_text(correct,800,300);
  245. score = score_add(score);
  246. gfx_text(scoretwo,800,400);
  247. gfx_text(guessthree,800,450);
  248. gfx_text(between,800,500);
  249. printf("%d\n",score);
  250. c = gfx_wait();
  251. gfx_clear();
  252. }//136
  253.  
  254. else if (score == 0)
  255. {//140
  256. gfx_clear();
  257. gfx_text(correct,800,300);
  258. score = score_add(score);
  259. gfx_text(scoreone,800,400);
  260. gfx_text(guesstwo,800,450);
  261. gfx_text(between,800,500);
  262. printf("%d\n",score);
  263. c = gfx_wait();
  264. gfx_clear();
  265. }//136
  266. }
  267.  
  268. else//wrong condition
  269. {//163
  270. if (guess == 3)
  271. {
  272. gfx_clear();
  273. gfx_text(wrong,800,300);
  274. guess = guess_minus(guess);
  275. gfx_text(scoreone,800,400);
  276. gfx_text(guesstwo,800,450);
  277. gfx_text(between,800,500);
  278. printf("%d\n",guess);
  279. c = gfx_wait();
  280. gfx_clear();
  281. }//155
  282.  
  283. else if(guess == 2)
  284. {
  285. gfx_clear();
  286. gfx_text(wrong,800,300);
  287. guess = guess_minus(guess);
  288. gfx_text(scorezero,800,400);
  289. gfx_text(guessone,800,450);
  290. gfx_text(between,800,500);
  291. printf("%d\n",guess);
  292. c = gfx_wait();
  293. gfx_clear();
  294. }//155
  295. }
  296.  
  297. if (score == 2)
  298. {
  299. gfx_text(guessthree,100,250);
  300. gfx_text(scoretwo,100,200);
  301. }
  302. if (score == 1)
  303. {
  304. gfx_text(guesstwo,100,250);
  305. gfx_text(scoreone,100,200);
  306. }
  307. if (score == 0)
  308. {
  309. gfx_text(guessone,100,250);
  310. gfx_text(scorezero,100,200);
  311. }
  312.  
  313. gfx_text(levelthree,1100,100);
  314. gfx_text(black,100,100);
  315.  
  316. // setting line color
  317. gfx_color(0,0,0);
  318.  
  319. //drawing vertical grid
  320. gfx_line(600,0,600,1000);
  321. gfx_line(800,0,800,1000);
  322. gfx_line(1000,0,1000,1000);
  323.  
  324. //drawing horizontal grid
  325. gfx_line(600,200,1000,200);
  326. gfx_line(600,400,1000,400);
  327. gfx_line(600,600,1000,600);
  328. gfx_line(600,800,1000,800);
  329. gfx_line(600,1000,1000,1000);
  330.  
  331. // drawing in circles with different colors
  332.  
  333. gfx_color(0,0,255); //light blue
  334. gfx_fillcircle(700,100,150);
  335.  
  336. gfx_color(255,0,255); //pink
  337. gfx_fillcircle(900,100,150);
  338.  
  339. gfx_color(0,0,100); //dark blue
  340. gfx_fillcircle(700,300,150);
  341.  
  342. gfx_color(0,255,0); //light green
  343. gfx_fillcircle(900,300,150);
  344.  
  345. gfx_color(65,42,42); //brown
  346. gfx_fillcircle(700,500,150);
  347.  
  348. gfx_color(0,0,0); //black
  349. gfx_fillcircle(900,500,150);
  350.  
  351. gfx_color(0,128,0); //dark green
  352. gfx_fillcircle(700,700,150);
  353.  
  354. gfx_color(128,0,128); //purple
  355. gfx_fillcircle(900,700,150);
  356.  
  357. gfx_color(255,0,0); //red
  358. gfx_fillcircle(700,900,150);
  359.  
  360. gfx_color(255,255,0); //yellow
  361. gfx_fillcircle(900,900,150);
  362.  
  363. x = gfx_wait();
  364. gfx_color(0,0,0);
  365.  
  366. if ((x >= 800 && x <= 1000) || (y >= 400 && y <= 600)) // correct condition
  367. {
  368. if (score == 1)
  369. {//140
  370. gfx_clear();
  371. gfx_text(correct,800,300);
  372. score = score_add(score);
  373. gfx_text(scoretwo,800,400);
  374. gfx_text(guessthree,800,450);
  375. gfx_text(between,800,500);
  376. printf("%d\n",score);
  377. c = gfx_wait();
  378. gfx_clear();
  379. }//136
  380.  
  381. else if (score == 0)
  382. {//140
  383. gfx_clear();
  384. gfx_text(correct,800,300);
  385. score = score_add(score);
  386. gfx_text(scoreone,800,400);
  387. gfx_text(guesstwo,800,450);
  388. gfx_text(between,800,500);
  389. printf("%d\n",score);
  390. c = gfx_wait();
  391. gfx_clear();
  392. }//136
  393. }
  394.  
  395. else//wrong condition
  396. {//163
  397. if (guess == 3)
  398. {
  399. gfx_clear();
  400. gfx_text(wrong,800,300);
  401. guess = guess_minus(guess);
  402. gfx_text(scoreone,800,400);
  403. gfx_text(guesstwo,800,450);
  404. gfx_text(between,800,500);
  405. printf("%d\n",guess);
  406. c = gfx_wait();
  407. gfx_clear();
  408. }//155
  409.  
  410. else if(guess == 2)
  411. {
  412. gfx_clear();
  413. gfx_text(wrong,800,300);
  414. guess = guess_minus(guess);
  415. gfx_text(scorezero,800,400);
  416. gfx_text(guessone,800,450);
  417. gfx_text(between,800,500);
  418. printf("%d\n",guess);
  419. c = gfx_wait();
  420. gfx_clear();
  421. }//155
  422.  
  423.  
  424. }//66
  425. }//92
  426.  
  427. }//47
  428.  
  429.  
  430. }//8
  431.  
  432. int score_add(int score1)
  433. {
  434. score1 = score1 + 1;
  435. return(score1);
  436. }
  437.  
  438. int score_minus(int score1)
  439. {
  440. score1 = --score1;
  441. return(score1);
  442. }
  443.  
  444. int guess_add(int guess1)
  445. {
  446. guess1 = ++guess1;
  447. return(guess1);
  448. }
  449.  
  450. int guess_minus(int guess1)
  451. {
  452. guess1 = --guess1;
  453. return(guess1);
  454. }
Add Comment
Please, Sign In to add comment