NabzPlays
NabzPlays
Explore posts from servers
JCHJava Community | Help. Code. Learn.
Created by NabzPlays on 10/16/2024 in #java-help
Need help with fixing bug of ball not moving
still need help
12 replies
JCHJava Community | Help. Code. Learn.
Created by NabzPlays on 10/16/2024 in #java-help
Need help with fixing bug of ball not moving
12 replies
JCHJava Community | Help. Code. Learn.
Created by NabzPlays on 10/16/2024 in #java-help
Need help with fixing bug of ball not moving
void moveBall() {
ballX =+ speedX;
ballY =+ speedY;
ballX = constrain(ballX, 0, width);
ballY = constrain(ballY, 0, height);
}

void bounceBall() {
if ((ballX - (ballWidth /2)) <= 0){
speedX = -speedX;
}
else if ((ballX + (ballWidth / 2)) >= width){
speedX = -speedX;
}
else if ((ballY - (ballWidth /2)) <= 0){
speedY = -speedY;
}
else if ((ballY + (ballWidth / 2)) >= height){
speedY = -speedY;
}
}
void draw() {
background(127);
// draw the ball
drawColourCircle(ballX, ballY, ballWidth, color(255, 0, 0));
// move the ball
moveBall();

if (checkCollide(ballX, ballY, ballWidth, holeX, holeY, holeWidth)) {
initializeHole();
initializeSpeed();
}

// bounce the ball ( if necessary)
bounceBall();
drawColourCircle(holeX, holeY, holeWidth, color(0));
}
void moveBall() {
ballX =+ speedX;
ballY =+ speedY;
ballX = constrain(ballX, 0, width);
ballY = constrain(ballY, 0, height);
}

void bounceBall() {
if ((ballX - (ballWidth /2)) <= 0){
speedX = -speedX;
}
else if ((ballX + (ballWidth / 2)) >= width){
speedX = -speedX;
}
else if ((ballY - (ballWidth /2)) <= 0){
speedY = -speedY;
}
else if ((ballY + (ballWidth / 2)) >= height){
speedY = -speedY;
}
}
void draw() {
background(127);
// draw the ball
drawColourCircle(ballX, ballY, ballWidth, color(255, 0, 0));
// move the ball
moveBall();

if (checkCollide(ballX, ballY, ballWidth, holeX, holeY, holeWidth)) {
initializeHole();
initializeSpeed();
}

// bounce the ball ( if necessary)
bounceBall();
drawColourCircle(holeX, holeY, holeWidth, color(0));
}
12 replies
JCHJava Community | Help. Code. Learn.
Created by NabzPlays on 10/16/2024 in #java-help
Need help with fixing bug of ball not moving
I don't want to show all my code for obvious reason but heres some of it which i think my be causing the bug
12 replies
JCHJava Community | Help. Code. Learn.
Created by NabzPlays on 10/16/2024 in #java-help
Need help with fixing bug of ball not moving
No description
12 replies
JCHJava Community | Help. Code. Learn.
Created by NabzPlays on 10/16/2024 in #java-help
Need help with fixing bug of ball not moving
heres the work sheets:
12 replies
JCHJava Community | Help. Code. Learn.
Created by NabzPlays on 10/16/2024 in #java-help
Need help with fixing bug of ball not moving
currently this is the point i got to
12 replies