We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
Moved the topic and formatted code. See To newcomers in this forum: read attentively these instructions.
Also check out the examples shipped with Processing. There is one about circle collisions.
This is a great library for what you want:
http://www.looksgood.de/libraries/Ani/
There are all kind of options for easing: http://www.looksgood.de/libraries/Ani/Ani_Cheat_Sheet.pdf