CodingTrain / CodingTrain/Suggestion-Box

Bumping Ball probleme using functions

Open
#931 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
570
Forks
85
PR merge metrics
No merged PRs in 30d

Description

I tried to add an option in my BumpingBall code. I tried to add a new ball using the function. But the balls don't move. I'm a new learned programmer so I don't understand every thing but i try to.
Thank you for helping me !

void setup(){
size (640,360);
}

void draw(){
background(150);
//I add 2 balls and add the coordonate and the speed
ball(0, 0, 3, 4);
ball(100, 300, 2, 5.5);
}
// I set the void function
void ball(float x,float y,float sx,float sy){
fill(255);
ellipse(x, y, 30, 30);
//speed
x = x + sx;
y = y + sy;
//conditions
if ((x > width) | (x < 0)){
sx = -sx;
}
if ((y < 0) | (y > height)){
sy = -sy;
}
}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.