Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. float rectX;
  2. float rectY;
  3. float rectR;
  4. float sizew;
  5. float sizeh;
  6. float size2w;
  7. float size2h;
  8. float rect2X;
  9. float rect2Y;
  10. float rect2R ;
  11. float x = 200;
  12. float y = 350;
  13. float ballR = 25;
  14. int lives = 3;
  15. float gettingrekt = 0;
  16. float gettingrekt2 = 0;
  17. float Fspeed;
  18.  
  19. void setup() {
  20. size(600, 400);
  21. rectY = 0;
  22. rectX = random(0, 600);
  23. rect2Y = 0;
  24. rect2X = random(0, 600);
  25. sizew = random(50, 70);
  26. sizeh = sizew;
  27. size2w = random(50, 80);
  28. size2h = size2w;
  29. rectR = sizew / 2;
  30. rect2R = size2w / 2;
  31. Fspeed = rect2Y += random(1, 10);
  32. rectY += random(1,10);
  33. }
  34.  
  35.  
  36. void draw() {
  37. background(0, 0, 0);
  38. String s = "Lives:" +lives;
  39. textSize(32);
  40. fill(50);
  41. text(s, 10, 25);
  42.  
  43. if ( dist(rectX, rectY, x, y)<= ballR + rectR) {
  44. if (gettingrekt == 0) {
  45. lives -= 1;
  46. gettingrekt = 1;
  47. }
  48.  
  49. background(255, 0, 0);
  50. } else {
  51. gettingrekt = 0;
  52. }
  53.  
  54. if ( dist(rect2X, rect2Y, x, y)<= ballR + rectR) {
  55. if (gettingrekt2 == 0) {
  56. lives -= 1;
  57. gettingrekt2 = 1;
  58. }
  59. background(255, 0, 0);
  60. } else {
  61. gettingrekt2 = 0;
  62. }
  63. if (lives <= 0) {
  64. background(255, 5, 5);
  65. String t = "GameOver";
  66. textSize(64);
  67. fill(50);
  68. text(t, 150, 200);
  69. String r = "Press Shift to Continue";
  70. textSize(32);
  71. fill(50);
  72. text(r, 125, 250);
  73. rectY = 0;
  74. rect2Y = 0;
  75. }
  76. noStroke();
  77.  
  78. Fspeed = rectY += random(2,8);
  79.  
  80. fill(255, 0, 0);
  81. ellipse( rectX, rectY, size2h, size2w);
  82. if (rectY > height) {
  83. Fspeed = rectY += random(1,8);
  84. rectX = random(0, 600);
  85. size2w= random(50, 75);
  86. size2h = size2w;
  87. rectY = 0;
  88.  
  89.  
  90. }
  91. rect2Y += random(1, 10);
  92. fill(255, 0, 0);
  93. ellipse( rect2X, rect2Y, sizeh, sizew);
  94. if (rect2Y > height) {
  95. rect2Y = 0;
  96. rect2X = x;
  97. sizew= random(50, 75);
  98. sizeh = sizew;
  99. rect2Y += random(1, 10);
  100. }
  101. fill(255);
  102. ellipse(x, y, 50, 50);
  103. if (x > width)
  104. x = 590;
  105. if (x < 0 )
  106. x = 15;
  107. {
  108. }
  109. }
  110. void keyPressed() {
  111. if (key == CODED) {
  112. if (keyCode == LEFT)
  113. x -=25;
  114. if (keyCode == RIGHT)
  115. x+= 25;
  116. if (keyCode == SHIFT) {
  117. rect2Y += random(1,10);
  118. rectY += random(1,10);
  119. background(0, 0, 0);
  120. lives = 3;
  121. }
  122. }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement