Advertisement
Guest User

Working draw()

a guest
May 23rd, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. void draw()
  2. {
  3.  
  4. background(255);
  5. if (screen == 0)//main menu
  6. {
  7. image(photo,0,0);
  8. }
  9. else if (screen == 1)//Gamemodes
  10. {
  11. image(photo2,0,0);
  12. }
  13. else if (screen == 2)//How to play
  14. {
  15. image(photo3,0,0);
  16. }
  17. else if (screen == 4)//Credits
  18. {
  19. image(photo5,0,0);
  20. }
  21. else if (screen == -1) //settings menu
  22. {
  23. image(photo4,0,0);
  24. }
  25. else if (screen==5)
  26. {
  27. //chooseGameMode(1);
  28. }
  29. else if (screen ==6)
  30. {
  31. }
  32. else if (screen ==7)
  33. {
  34. }
  35. //Selected boxes for settings menu
  36. if (screen == -1)
  37. {
  38. if (a == 1)
  39. {
  40. stroke(224,255,255);
  41. strokeWeight(3);
  42. noFill();
  43. rect(465,175,80,70);
  44. }
  45. else if (a == 2)
  46. {
  47. stroke(224,255,255);
  48. strokeWeight(3);
  49. noFill();
  50. rect(583,180,65,63);
  51. }
  52. else if (a == 3)
  53. {
  54. stroke(224,255,255);
  55. strokeWeight(3);
  56. noFill();
  57. rect(695,177,60,68);
  58. }
  59. if (b==1)
  60. {
  61. stroke(224,255,255);
  62. strokeWeight(3);
  63. noFill();
  64. rect(350,280,350,43);
  65. }
  66. else if (b==2)
  67. {
  68. stroke(224,255,255);
  69. strokeWeight(3);
  70. noFill();
  71. rect(40,368,360,40);
  72. }
  73. else if (b==3)
  74. {
  75. stroke(224,255,255);
  76. strokeWeight(3);
  77. noFill();
  78. rect(440,367,320,40);
  79. }
  80. else if (b==4)
  81. {
  82. stroke(224,255,255);
  83. strokeWeight(3);
  84. noFill();
  85. rect(440,445,300,40);
  86. }
  87. else if (b==5)
  88. {
  89. stroke(224,255,255);
  90. strokeWeight(3);
  91. noFill();
  92. rect(20,443,370,40);
  93. }
  94. if (c==1)
  95. {
  96. stroke(224,255,255);
  97. strokeWeight(3);
  98. noFill();
  99. rect(415,670,90,55);
  100. }
  101. else if (c==2)
  102. {
  103. stroke(224,255,255);
  104. strokeWeight(3);
  105. noFill();
  106. rect(675,670,140,55);
  107. }
  108. if (d==1)
  109. {
  110. stroke(224,255,255);
  111. strokeWeight(3);
  112. noFill();
  113. rect(425,823,90,55);
  114. }
  115. else if (d==2)
  116. {
  117. stroke(224,255,255);
  118. strokeWeight(3);
  119. noFill();
  120. rect(685,823,130,55);
  121. }
  122. }
  123. //actual game
  124. if(screen ==6)
  125. {
  126. fill(0);
  127. textSize(14);
  128. text("Score = " + g , 850,100);
  129. if (g>=best)
  130. best = g;
  131. strokeWeight(1);
  132. fill(0,255,0);
  133. text("Best = " + best, 850, 150);
  134. }
  135. else if(screen==8)
  136. {
  137. strokeWeight(1);
  138. fill(0,255,0);
  139. text("Best = " + best, 850, 150);
  140. gameOver=false;
  141. }
  142. else if(screen==7)
  143. {
  144.  
  145. }
  146. //restart the game
  147. if (gameOver ==true && (screen == 6 || screen == 7 || screen == 8))
  148. {
  149. if(gameOver ==true && (screen == 6 || screen == 7 || screen == 8))
  150. {
  151. image (photo10,0,0);
  152. }
  153. if (restart)
  154. {
  155. gameOver = false;
  156. s1 = new Snake (10, "arrows");
  157. if (mode == 2)
  158. {
  159. s2 = new Snake(20, "wasd");
  160. s1.setOtherSnake(s2);
  161. s2.setOtherSnake(s1);
  162. }
  163. if (mode == 3)
  164. {
  165. s3 = new Snake(20, "computer");
  166. snakeAi = new ComputerSnake();
  167. s1.setOtherSnake(s3);
  168. s3.setOtherSnake(s1);
  169. }
  170. restart = false;
  171. }
  172. }
  173. //bracket
  174. if (mode == 1)
  175. {
  176. if(s1.drawSnake())
  177. {
  178. renderer.drawCollision();
  179. gameOver = true;
  180. g=3;
  181. }
  182. else
  183. {
  184. if (mode == 3)
  185. {
  186. renderer.drawBoardComputer();
  187. }
  188. if (mode == 2)
  189. {
  190. renderer.drawBoardMulti();
  191. }
  192. if (mode == 1)
  193. {
  194. renderer.drawBoardSingle();
  195. fill(0);
  196. textSize(14);
  197. text("Score = " + g , 850,100);
  198. }
  199. }
  200. }
  201. else if (mode == 2)
  202. {
  203. if(s1.drawSnake() || s2.drawSnake())
  204. {
  205. renderer.drawCollision();
  206. gameOver = true;
  207. g=3;
  208. }
  209. else
  210. {
  211. if (mode == 2) renderer.drawBoardMulti();
  212. if (mode == 1) renderer.drawBoardSingle();
  213. }
  214. }
  215. else if (mode == 3)
  216. {
  217. if(s1.drawSnake() || s3.drawSnake())
  218. {
  219. renderer.drawCollision();
  220. gameOver = true;
  221. g=3;
  222. }
  223. else
  224. {
  225. if (mode == 3) renderer.drawBoardComputer();
  226. if (mode == 2) renderer.drawBoardMulti();
  227. if (mode == 1) renderer.drawBoardSingle();
  228. }
  229. }
  230.  
  231. //draw picture over powerup
  232. if (p.isAvailable == true)
  233. {
  234. if (p.choose == 1)
  235. {
  236. image(photo6,(p.x * 20.0), (p.y * 20.0));
  237. }
  238. if (p.choose == 2)
  239. {
  240. image(photo7,(p.x * 20.0), (p.y * 20.0));
  241. }
  242. if (p.choose == 3)
  243. {
  244. image(photo8,(p.x * 20.0), (p.y * 20.0));
  245. }
  246. if (p.choose == 4)
  247. {
  248. image(photo9,(p.x * 20.0), (p.y * 20.0));
  249. }
  250. }
  251. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement