Advertisement
GoldenSoulGamer

Untitled

Dec 11th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. float x = 0;
  2. float d = 0.98;
  3. float move = 0;
  4. float y = 0;
  5. float ycons;
  6. float z = 0.98;
  7.  
  8. void setup(){
  9. size(500, 500);
  10. ellipseMode(CENTER);
  11. }
  12. void draw() {
  13. background(0);
  14. rotat();
  15. bombdisp();
  16. bounce();
  17. }
  18. //if the y value changes, it makes stuff rotate in that form
  19. // put the rotat and y in one variable -- > then bounce!
  20. // pair rotat and display together, make the y
  21. void rotat() {
  22. translate(250,250);
  23. println(move);
  24. move += PI/200;
  25. rotate(PI + move);
  26. }
  27. void bounce() {
  28. y = y + d;
  29. d = d + z;
  30. // When it hits the ground, it "bounces" (changes trajectory)
  31. //println(d);
  32. if (y >= height) {
  33. d = -d;
  34. d = d + (2.857 * z);
  35. }
  36.  
  37. }
  38.  
  39. void bombdisp() {
  40. ycons = (int)constrain(y, 0.0, height);
  41. fill(0);
  42. ellipse(x, y, 30, 30);
  43. println(x);
  44. println(y);
  45. fill(100, 100, 5);
  46. stroke(255, 255, 0);
  47. strokeWeight(2);
  48. arc(x-10, y, 10, 10, 0.5, PI+0.5);
  49. arc(x+10, y, 10, 10 ,-0.5, PI-0.5);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement