Moving an object and having it move smoothly.

edited April 2014 in How To...

I am making a simple billiards game where I place a cue ball and then an eight ball. I then have the cue ball go towards the eightball and hit it. I know that I need to apply a collision which is a bit of a struggle to understand but I would like to know what I can do to make it move. Here's my code.

Ball b1,b2;
int mouseClick=0;
void setup(){
  b1 = new Ball(mouseX, mouseY, 50);
  b2 = new Ball(mouseX, mouseY, 50);
  size(600,400);


}



void draw(){
  background(0,153,0);
  fill(255,255,255);
  b1.update();
  fill(0,0,0);
  b2.update();
}


void mousePressed(){
  mouseClick++;
  if (mouseClick==1)
  b1 = new Ball(mouseX, mouseY, 50);
  else if(mouseClick==3)
  b1.xpos+=5;


  if (mouseClick==2)
  b2 = new Ball(mouseX, mouseY,50);

   }

Answers

Sign In or Register to comment.