Make a squishy bouncing ball

How to make a ball flatten when it bounces against the walls. Use arcs? Maybe something else? Just wondering, if we use arc, how much to actually 'squish'?

Use this as the base:

int c;
float xPos;
float yPos;
int x;
int y;

void setup(){
  size(600,600);
  xPos = random(50,550);
  yPos = random(50,550);
  x = 1;
  y = 1;
}

void draw(){
  background(0);
  c = color(255,255,255);
  fill(c);
  noStroke();
  ellipse(xPos,yPos,50,50);
  xPos = xPos + 2 * x;
  yPos = yPos + 2 * y;
  if(xPos > 575 ||xPos < 25) x *= -1;
  if(yPos > 575 ||yPos < 25) y *= -1;
}
Tagged:

Answers

  • Just thought about something else. Instead of flattening, maybe turning into an oval would be easier? Not sure.

  • Hm

    Try search on openprocessing.org

    My idea would be to calculate 360 dots / ellipses that make up the circle like a swarm (see particles)

    Now, when it touches a wall, I dunno

    Some stay on the wall..... when the center (invisible) of the big circles touches the wall, it turns, dragging the other spheres with it

    like on a chain the small spheres are connected with springs (See examples)

    They want to fall back in a certain Position around the Center

Sign In or Register to comment.