{Processing} Problem With Gravity Startup

int startTimeMs;
// The time until the game starts, in milliseconds
final int startDelayMs = 5000;
boolean atStartup = true;
int gameWidth = 600;
int gameHeight = 500;
int diameter = 20;
//Ball Placement
float x,y;
int dx = -3;
int dy = 1;
//Value of lives
int score = 0;
int lives = 5;
//Gravity
float gravity = 0.98;
float bounce = -1;

void setup(){
size(600,500);
// Current time, in milliseconds
startTimeMs = millis();
noStroke();
x = random(0,width-diameter);
y = random(0,height-diameter);
}

void draw(){
//Countdown for Startup
if (atStartup) {
// The current time, in milliseconds
int curTimeMs = millis();
// The remaining time in the startup period
int startupTimeRemainingMs = startDelayMs - (curTimeMs - startTimeMs);
startScreen(startupTimeRemainingMs);
atStartup = startupTimeRemainingMs > 0;
// Short-circuit if we’re still in the startup phase.
return;
}
//Countdown Screen
background(240);
fill(0);
textAlign(CENTER,CENTER);
text(“GO!”, gameWidth/2, gameHeight/2);

//Game
background(60,211,202);
fill(0);
text(“Score:” + score,10,10);
text(“Lives:” + lives,10,30);
//Where the ball positions
ellipse(x,y,diameter,diameter);
if((x > width-diameter/2) || (x < diameter/2)) {
dx*=-1;
fill(random(0,255),random(0,255),random(0,255));
}
if(y > height-diameter/2 || y < diameter/2) {
dy*=-1;
fill(255);
}
//Changes in diameter
x=x+dx;
y=y+dx;

//
}

//Start Screen
void startScreen(int remainingTimeMs){
background(50);
textSize(100);
fill(0);
textAlign(CENTER,CENTER);
// Show the remaining time, in seconds;
// show n when there are n or fewer seconds remaining.
text(ceil(remainingTimeMs/1000.0), gameWidth/2, gameHeight/2);
}

//Lives
void mousePressed() {
if(dist(mouseX,mouseY,x,y) < 20) {
textSize(10);
score +=1;
}else{
lives = lives -1;
}
}

Sorry, but what’s your question?

Have you tried debugging your program to understand exactly what your code is doing? Which line of code is behaving differently from what you expected?

Can you please narrow your problem down to a MCVE instead of just posting your full sketch? Also please make sure your code is correctly formatted by highlighting your code and pressing the code button in the editor.