Ball to ball collision

I am trying to make it so that the circle that is moving (circleX) isn’t hit by the circles that are obstacles (circleD). I’ve tried a lot of different things and can’t find what’s wrong.

float xspeed = 2.5;

float x,y;

boolean upPressed = false;
boolean downPressed = false;
boolean leftPressed = false;
boolean rightPressed = false;

float circleX = 50;
float circleY = 487;

PImage img1, img2, img3;
float[] circleD = new float[180];

int time;
int wait = 5000;

void setup() {
size(1000, 500);
time=millis();
rectMode(CENTER);
img1 = loadImage(“stars.gif”);
img2 = loadImage(“splash_screen_example2.png”);
img3 = loadImage(“character_1.png”);

for (int i = 0; i < circleD.length; i++) {
circleD[i] = random(height);
}
}

void draw() {

background(#18468E);
//stars
image(img1, 0, 0);
img1.resize(1000,500);
tint(255,255); // Tint blue
image(img1, 0, 0);

//text
fill(#FFFFFF);
textSize(100);
text(“Red”, 400, 187);
textSize(75);
text(“Ball”, 420, 247);
textSize(50);
text(“Dash”,440,287);

fill(#FF0303);
textSize(100);
text(“Red”, 400, 200, +5000);
textSize(75);
text(“Ball”, 420, 260);
textSize(50);
text(“Dash”,440,300);

if (millis() - time > wait){ //splash screen

background(50);
fill(#F57C0A);
for (int i = 0; i < circleD.length; i++) {
float circleE = width * i / circleD.length;
ellipse(circleE, circleD[i], 18, 18);

circleD[i]++;

if (circleD[i] > height) {
  circleD[i] = 0;

}
}
}
if (upPressed) {
circleY=circleY-xspeed;

}
if (downPressed) {
circleY=circleY+xspeed;
}
if (leftPressed) {
circleX=circleX-xspeed;
}
if (rightPressed) {
circleX=circleX+xspeed;

}
fill(#FF0303);
ellipse(circleX, circleY, 13, 13);
edges();

}

void keyPressed() {
if (keyCode == UP) {
upPressed = true;
}
else if (keyCode == DOWN) {
downPressed = true;
}

if (keyCode == LEFT) {
leftPressed = true;
}
else if (keyCode == RIGHT) {
rightPressed = true;
}
}

void keyReleased() {
if (keyCode == UP) {
upPressed = false;
}
else if (keyCode == DOWN) {
downPressed = false;
}
else if (keyCode == LEFT) {
leftPressed = false;
}
else if (keyCode == RIGHT) {
rightPressed = false;
}
}
void mousePressed() {
loop();
}

void mouseReleased() {
noLoop();
}
void edges() {
if (circleX > width){
image(img2, 0, 0);
img2.resize(1000,500);

xspeed = xspeed * 0.9;
}
if (circleX < width - 1000){
image(img2, 0, 0);
img2.resize(1000,500);

xspeed = xspeed * 0.9;
}
if (circleY > height){
image(img2, 0, 0);
img2.resize(1000,500);
xspeed = xspeed * 0.9;
}
if (circleY < height - 500){
image(img2, 0, 0);
img2.resize(1000,500);
xspeed = xspeed * 0.9;
}
}

When you remove gravity this is it: BouncyBubbles \ Examples \ Processing.org

Hey, and welcome to the forum!

Great to have you here!

Warm regards,

Chrisir :wink: