Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.40 KB | None | 0 0
  1. int level = -1;
  2. int lives = 3;
  3. String Start = "Click here Start";
  4. String Reset = "Press R to Restart!";
  5. String Cheat = "Want to cheat? \n Type 'F' \n to skip to \n the end!";
  6. String life5 = "You have '5' Lives!";
  7. String life4 = "You have '4' Lives!";
  8. String life3 = "You have '3' Lives!";
  9. String life2 = "You have '2' Lives!";
  10. String life1 = "You have '1' Life!";
  11. String lifes = life3;
  12. PImage maze;
  13. PImage maze2;
  14. PImage maze3;
  15. PImage spc;
  16. PImage etype;
  17. PImage star;
  18. Enemy enemy1 = new Enemy(100,100,20);
  19. Enemy enemy2 = new Enemy(0,200,40);
  20. PImage win;
  21. PImage start;
  22. PImage loser;
  23. PImage bomb;
  24. PImage grenade;
  25. PImage settinglogo;
  26. PImage nathan;
  27. color bColor = color(0,0,0);
  28. int settings = 0;
  29. int eimage = 1;
  30. Ball ball1 = new Ball('w', 's', 'a', 'd', 10000 , 10 , 10, 7, 5, 5);
  31. void setup(){
  32. size(800,600);
  33. maze = loadImage("maze.png");
  34. maze2 = loadImage("maze2.jpg");
  35. maze3 = loadImage("maze3.gif");
  36. win = loadImage("win.jpg");
  37. loser = loadImage("loser.jpg");
  38. settinglogo = loadImage("settinglogo.png");
  39. spc = loadImage("spc.png");
  40. start = loadImage("start.gif");
  41. etype = loadImage("etype.png");
  42. star = loadImage("star.png");
  43. nathan = loadImage("nathan.jpg");
  44. bomb = loadImage("bomb.png");
  45. grenade = loadImage("greande.png");
  46. fill(0);
  47. textSize(10);
  48. }
  49.  
  50. void draw(){
  51. if (level == -1){
  52. lives = 3;
  53. settings = -1;
  54. background(0,255,0);
  55. image(settinglogo,250,400,50,50);
  56. image(start,100,150,400,250);
  57. fill(0);
  58. text(Reset,620,25);
  59. text(lifes,620,50);
  60. }
  61. if (level == 1){
  62. settings = -1;
  63. image(maze,0,0,600,600);
  64. enemy1.show();
  65. enemy1.move3(millis());
  66. fill(bColor);
  67. fill(0,255,0);
  68. rect(600,0,800,600);
  69. fill(0);
  70. text(Reset,620,25);
  71. text(lifes,620,50);
  72. text(Cheat,620,75);
  73. textSize(10);
  74. }
  75. if (level == 2){
  76. settings = -1;
  77. image(maze2,0,0,600,600);
  78. fill(bColor);
  79. enemy2.show();
  80. enemy2.move2(millis());
  81. fill(0,255,0);
  82. rect(600,0,800,600);
  83. fill(0);
  84. text(Reset,620,25);
  85. text(lifes,620,50);
  86. text(Cheat,620,75);
  87. textSize(10);
  88. }
  89. if (level == 3){
  90. settings = -1;
  91. image(maze3,0,0,600,600);
  92. fill(bColor);
  93. enemy1.show();
  94. enemy1.move(millis());
  95. fill(0,255,0);
  96. rect(600,0,800,600);
  97. fill(0);
  98. text(Reset,620,25);
  99. text(lifes,620,50);
  100. text(Cheat,620,75);
  101. textSize(10);
  102. }
  103. if (level == 4){
  104. settings = -1;
  105. image(win,0,0,600,600);
  106. }
  107.  
  108. if(keyPressed){
  109. if (key == 'r'){
  110. level = -1;
  111. ball1 = new Ball('w', 's', 'a', 'd', 10000 , 10 , 10, 7, 5, 5);
  112. lives = 3;
  113. }
  114. if (key == 'f' && level == 1){
  115. ball1 = new Ball('w', 's', 'a', 'd', width-490 , height-25 , 8, 3, 5, 5);
  116. }
  117. if (key == 'f' && level == 2){
  118. ball1 = new Ball('w', 's', 'a', 'd', width-430 , height-50 , 8, 3, 5, 5);
  119. }
  120. if (key == 'f' && level == 3){
  121. ball1 = new Ball('w', 's', 'a', 'd', width-760 , height-400 , 8, 3, 5, 5);
  122. }
  123. }
  124. if (level == -1 && mousePressed == true && mouseX > 100 && mouseX < 500 && mouseY > 150 && mouseY < 400){
  125. level = 1;
  126. image(maze,0,0,600,600);
  127. noStroke();
  128. fill(bColor);
  129. ball1 = new Ball('w', 's', 'a', 'd', 280 , 10 , 8, 3, 5, 5);
  130. }
  131. if (level == -1 && mousePressed == true && mouseX > 200 && mouseX < 300 && mouseY > 350 && mouseY <450){
  132. level = -2;
  133. }
  134. if (level == -2){
  135. background(255);
  136. image(etype,60,200,550,280);
  137. image(spc,75,40,450,100);
  138. fill(255);
  139. noStroke();
  140. rect(20,60,100,100);
  141. rect(20,40,500,18);
  142. fill(150,100,255);
  143. noStroke();
  144. ellipse(150,150,25,25);
  145. fill(0,255,255);
  146. ellipse(250,150,25,25);
  147. fill(0,0,255);
  148. ellipse(350,150,25,25);
  149. fill(150,255,0);
  150. ellipse(450,150,25,25);
  151. //
  152. noStroke();
  153. image(star,150,350,25,25);
  154. image(nathan,250,350,25,25);
  155. image(bomb,350,350,25,25);
  156. image(grenade,450,350,25,25);
  157. image(settinglogo,250,450,50,50);
  158. }
  159. if (level == -2 && mousePressed == true && mouseX > 145 && mouseX < 170 && mouseY > 145 && mouseY <170){
  160. settings = 1;
  161. }
  162. if (level == -2 && mousePressed == true && mouseX > 145 && mouseX < 170 && mouseY > 345 && mouseY <370){
  163. eimage = 1;
  164. }
  165. if (level == -2 && mousePressed == true && mouseX > 245 && mouseX < 270 && mouseY > 345 && mouseY <370){
  166. eimage = 2;
  167. }
  168. if (level == -2 && mousePressed == true && mouseX > 345 && mouseX < 370 && mouseY > 345 && mouseY <370){
  169. eimage = 3;
  170. }
  171. if (level == -2 && mousePressed == true && mouseX > 445 && mouseX < 470 && mouseY > 345 && mouseY <370){
  172. eimage = 4;
  173. }
  174. if (level == -2 && mousePressed == true && mouseX >= 245 && mouseX <= 270 && mouseY >= 145 && mouseY <= 170){
  175. settings = 2;
  176. }
  177. if (level == -2 && mousePressed == true && mouseX >= 345 && mouseX <= 370 && mouseY >= 145 && mouseY <= 170){
  178. settings = 3;
  179. }
  180. if (level == -2 && mousePressed == true && mouseX >= 445 && mouseX <= 470 && mouseY >= 145 && mouseY <= 170){
  181. settings = 4;
  182. }
  183. if (level == -2 && mousePressed == true && mouseX >= 200 && mouseX <= 300 && mouseY >= 450 && mouseY <= 550){
  184. level = -1;
  185. }
  186. if (settings == 1){
  187. bColor = color(150,100,255);
  188. fill(150,100,255);
  189. stroke(0);
  190. strokeWeight(7);
  191. ellipse(150,150,25,25);
  192. noStroke();
  193. fill(255);
  194. rect(20,60,100,100);
  195. rect(20,40,500,18);
  196. }
  197. if (settings == 2){
  198. fill(150,100,255);
  199. noStroke();
  200. ellipse(150,150,25,25);
  201. bColor = color(0,255,255);
  202. fill(0,255,255);
  203. stroke(0);
  204. strokeWeight(7);
  205. ellipse(250,150,25,25);
  206. noStroke();
  207. fill(255);
  208. rect(20,60,100,100);
  209. rect(20,40,500,18);
  210. }
  211. if (settings == 3){
  212. fill(150,100,255);
  213. noStroke();
  214. ellipse(150,150,25,25);
  215. fill(0,255,255);
  216. ellipse(250,150,25,25);
  217. bColor = color(0,0,255);
  218. fill(0,0,255);
  219. stroke(0);
  220. strokeWeight(7);
  221. ellipse(350,150,25,25);
  222. noStroke();
  223. fill(255);
  224. rect(20,60,100,100);
  225. rect(20,40,500,18);
  226. }
  227. if (settings == 4){
  228. fill(150,100,255);
  229. noStroke();
  230. ellipse(150,150,25,25);
  231. fill(0,255,255);
  232. ellipse(250,150,25,25);
  233. fill(0,0,255);
  234. ellipse(350,150,25,25);
  235. bColor = color(150,255,0);
  236. fill(150,255,0);
  237. stroke(0);
  238. strokeWeight(7);
  239. ellipse(450,150,25,25);
  240. noStroke();
  241. fill(255);
  242. rect(20,60,100,100);
  243. rect(20,40,500,18);
  244. }
  245. if (settings == 5){
  246. fill(150,100,255);
  247. noStroke();
  248. ellipse(150,150,25,25);
  249. fill(0,255,255);
  250. ellipse(250,150,25,25);
  251. fill(0,0,255);
  252. ellipse(350,150,25,25);
  253. bColor = color(150,255,0);
  254. fill(150,255,0);
  255. stroke(0);
  256. strokeWeight(7);
  257. ellipse(450,150,25,25);
  258. noStroke();
  259. fill(255);
  260. rect(20,60,100,100);
  261. rect(20,40,500,18);
  262. }
  263. if (ball1.isFinished(width-510,height-25,50,50) && level == 1 ){
  264. level = 2;
  265. fill(bColor);
  266. ball1 = new Ball('w', 's', 'a', 'd', 270 , 10 , 10, 7, 5, 5);
  267. lives = lives+1;
  268. }
  269. if (ball1.isFinished(width-430,height-25,50,50) && level == 2 ){
  270. level = 3;
  271. fill(bColor);
  272. ball1 = new Ball('w', 's', 'a', 'd', 475 , 10 , 10, 4, 5, 5);
  273. lives = lives+1;
  274. }
  275. if (ball1.isFinished(width-830,height-400,50,50) && level == 3 ){
  276. level = 4;
  277. fill(bColor);
  278. ball1 = new Ball('w', 's', 'a', 'd', 10000,10000 ,0, 0, 0, 0);
  279. lives = lives+1;
  280. }
  281. if (ball1.touchingWall() && level == 1){
  282. level = 1;
  283. fill(0,255,0);
  284. rect(600,0,800,600);
  285. lives = lives -1;
  286. ball1 = new Ball('w', 's', 'a', 'd', 280 , 10 , 8, 3, 5, 5);
  287. }
  288. if (ball1.touchingWall() && level == 2){
  289. level = 2;
  290. fill(0,255,0);
  291. rect(600,0,800,600);
  292. lives = lives -1;
  293. ball1 = new Ball('w', 's', 'a', 'd', 270 , 10 , 10, 4, 5, 5);
  294.  
  295. }
  296. if (ball1.touchingWall() && level == 3){
  297. level = 3;
  298. fill(0,255,0);
  299. rect(600,0,800,600);
  300. lives = lives -1;
  301. ball1 = new Ball('w', 's', 'a', 'd', 475 , 10 , 10, 4, 5, 5);
  302. }
  303. if (ball1.loseGame()){
  304. level = 5;;
  305. }
  306. if(level == 5){
  307. image(loser,0,0,800,600);
  308. ball1 = new Ball('w', 's', 'a', 'd', 10000 , 10 , 10, 7, 5, 5);
  309. }
  310.  
  311. if(lives == 1){
  312. lifes = life1;
  313. }
  314. if(lives == 2){
  315. lifes = life2;
  316. }
  317. if(lives == 3){
  318. lifes = life3;
  319. }
  320. if(lives == 4){
  321. lifes = life4;
  322. }
  323. if(lives == 5){
  324. lifes = life5;
  325. }
  326.  
  327.  
  328. ball1.show();
  329. ball1.move();
  330.  
  331. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement