Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Ball {
- float x;
- float y;
- float speedX;
- float speedY;
- float s;
- Ball(float _x, float _y) {
- x = _x;
- y = _y;
- speedX = random(-5, 5);
- speedY = random(-5, 5);
- s = random(5, 200);
- }
- void render() {
- circle(x, y, s);
- }
- void update() {
- x = x + speedX;
- y = y + speedY;
- }
- void bounce() {
- if (x>width || x<0) {
- speedX = -speedX;
- }
- if (y>height || y<0) {
- speedY = -speedY;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement