Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float x = 100;
- float y = 0;
- float geschw = 0;
- float gravitation = 0.1;
- Ball meinBall;
- Ball meinBall2;
- void setup () {
- size (200,200);
- meinBall = new Ball(10,10,2,100);
- meinBall2 = new Ball(10,100,2,103);
- }
- void draw () {
- background (100);
- fill (255);
- noStroke();
- meinBall.bewegen();
- meinBall.anzeigen();
- meinBall2.bewegen();
- meinBall2.anzeigen();
- }
- class Ball {
- float c;
- float xPos;
- float yPos;
- float xGeschw;
- Ball (float color_, float xPosition, float yPosition, float xGeschwindigkeit) {
- c = color_;
- xPos = xPosition;
- yPos = yPosition;
- xGeschw = xGeschwindigkeit;
- }
- void anzeigen () {
- ellipse(xPos,yPos,10,10);
- fill(c);
- }
- void bewegen () {
- y = y + geschw;
- geschw = geschw + gravitation;
- if (y > height) {
- geschw = geschw * -0.95;
- }
- }
- }
Add Comment
Please, Sign In to add comment