Advertisement
Guest User

Final

a guest
Apr 26th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. float rectX;
  2. float rectY;
  3. float rectR = 37.5;
  4. float ballX = 200;
  5. float ballY = 350;
  6. float ballR = 25;
  7. var lives = 3;
  8.  
  9.  
  10.  
  11.  
  12. void setup() {
  13. size(600,400);
  14. rectY = 0;
  15. rectX = random(0,600);
  16.  
  17.  
  18.  
  19. }
  20.  
  21. void draw() {
  22. background(0,0,0);
  23. string s = "Lives:" + lives;
  24. textSize(32);
  25. text(s, 10, 50);
  26.  
  27.  
  28.  
  29. if( dist(rectX,rectY,ballX,ballY)<= ballR + rectR) {
  30. background(255,0,0);
  31. lives = lives - 1;
  32. }
  33.  
  34. rectY += 8;
  35. fill(255)
  36. ellipse( rectX, rectY, 75, 75);
  37. if(rectY > height) {
  38. rectY = 0;
  39. rectX = random(0,600);
  40. }
  41.  
  42. ellipse( ballX, ballY, 50, 50);
  43.  
  44.  
  45. }
  46.  
  47. void keyPressed() {
  48. if(key == 'a') {
  49. ballX = ballX +100;
  50. }
  51.  
  52.  
  53.  
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement