Need help with fixing bug of ball not moving

Basically I have an assignment and we are using processing to do the assignment as the teacher basically told us to make a game where we have a small red ball moving around the canvas and if it touches the edges then it bounces back away and it if it hits the black ball its supposed to bounce back aswell and respawn a new black ball however I've been having a problem with it. For some reason the ball won't moving across the canvas rather it is just budging itself and even when i press x or y it doesnt do anything i uploaded a video of how it is supposed to work
9 Replies
JavaBot
JavaBot2mo ago
This post has been reserved for your question.
Hey @NabzPlays! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
NabzPlays
NabzPlaysOP2mo ago
currently this is the point i got to
NabzPlays
NabzPlaysOP2mo ago
heres the work sheets:
NabzPlays
NabzPlaysOP2mo ago
No description
No description
No description
No description
NabzPlays
NabzPlaysOP2mo ago
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
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));
}
NabzPlays
NabzPlaysOP2mo ago
JavaBot
JavaBot2mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
NabzPlays
NabzPlaysOP2mo ago
still need help
JavaBot
JavaBot2mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server