Guest User

Untitled

a guest
May 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. float x = 100;
  2. float y = 0;
  3. float geschw = 0;
  4. float gravitation = 0.1;
  5.  
  6. Ball meinBall;
  7. Ball meinBall2;
  8.  
  9. void setup () {
  10. size (200,200);
  11. meinBall = new Ball(10,10,2,100);
  12. meinBall2 = new Ball(10,100,2,103);
  13.  
  14. }
  15.  
  16. void draw () {
  17. background (100);
  18. fill (255);
  19. noStroke();
  20. meinBall.bewegen();
  21. meinBall.anzeigen();
  22. meinBall2.bewegen();
  23. meinBall2.anzeigen();
  24. }
  25.  
  26.  
  27. class Ball {
  28.  
  29. float c;
  30. float xPos;
  31. float yPos;
  32. float xGeschw;
  33.  
  34. Ball (float color_, float xPosition, float yPosition, float xGeschwindigkeit) {
  35. c = color_;
  36. xPos = xPosition;
  37. yPos = yPosition;
  38. xGeschw = xGeschwindigkeit;
  39. }
  40.  
  41. void anzeigen () {
  42. ellipse(xPos,yPos,10,10);
  43. fill(c);
  44.  
  45. }
  46.  
  47. void bewegen () {
  48. y = y + geschw;
  49. geschw = geschw + gravitation;
  50. if (y > height) {
  51. geschw = geschw * -0.95;
  52. }
  53. }
  54. }
Add Comment
Please, Sign In to add comment