When "circ" which follows your cursor touches the other circle i need to to remove the circle and create another circle that moves the same as the previous one
this is my code so far
var circle = new Circle(7);
var circ;
var dx = Randomizer.nextInt(-10,10);
var dy = Randomizer.nextInt(-10,10);
function start(){
mouseClickMethod(start);
circ = new Circle(20);
circ.setPosition(Randomizer.nextInt(0,400), Randomizer.nextInt(0,400));
add(circ);
setTimer(draw, 20);
mouseMoveMethod(paint);
}
function draw(){
checkWalls();
mouseClickMethod(circ.move(dx, dy));
}
function checkWalls(){
// Bounce off right wall
if(circ.getX() > getWidth()){
dx = -dx;
}
// Bounce off left wall
if(circ.getX() < 0){
dx = -dx;
}
// Bounce off bottom wall
if(circ.getY() > getHeight()){
dy = -dy;
}
// Bounce off top wall
if(circ.getY() < 0){
dy = -dy;
}
}
function ball1(){
mouseClickMethod(functionToCall);
}
function paint(e){
mouseMoveMethod(paint);
circle.setPosition(e.getX(), e.getY());
circle.setColor("red");
add(circle);
}
this is my code so far
var circle = new Circle(7);
var circ;
var dx = Randomizer.nextInt(-10,10);
var dy = Randomizer.nextInt(-10,10);
function start(){
mouseClickMethod(start);
circ = new Circle(20);
circ.setPosition(Randomizer.nextInt(0,400), Randomizer.nextInt(0,400));
add(circ);
setTimer(draw, 20);
mouseMoveMethod(paint);
}
function draw(){
checkWalls();
mouseClickMethod(circ.move(dx, dy));
}
function checkWalls(){
// Bounce off right wall
if(circ.getX() > getWidth()){
dx = -dx;
}
// Bounce off left wall
if(circ.getX() < 0){
dx = -dx;
}
// Bounce off bottom wall
if(circ.getY() > getHeight()){
dy = -dy;
}
// Bounce off top wall
if(circ.getY() < 0){
dy = -dy;
}
}
function ball1(){
mouseClickMethod(functionToCall);
}
function paint(e){
mouseMoveMethod(paint);
circle.setPosition(e.getX(), e.getY());
circle.setColor("red");
add(circle);
}