Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BouncingCircle {
- float xPos;
- float yPos;
- float xSpeed;
- color fillColor;
- BouncingCircle(color tempColor, float tempXPos, float tempYPos, float tempXSpeed) {
- fillColor = tempColor;
- xPos = tempXPos;
- yPos = tempYPos;
- xSpeed = tempXSpeed;
- }
- void display() {
- stroke(0);
- fill(fillColor);
- ellipse(xPos, yPos, 80, 80);
- }
- void bounce() {
- xPos = xPos + xSpeed;
- if ((xPos > width) || (xPos < 0)) {
- xSpeed = xSpeed * -1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement