Beginner question - could use a quick response
in
Programming Questions
•
6 months ago
I was working on this with my partner, but he never showed up today, so I am kind of lost.
All I want to do is take this and make the smiley ball bounce up and down only. Also, I have to add 2 more balls, so I would have 3 balls bouncing up and down.
Thank you in advance for any help!
void setup() {
size(500,500);
frameRate(15);
}
int posx;
int posy;
int xd = 10;
int yd = 20;
int wid =50;
int ht = 80;
void draw() {
background(#0024FF);
smiley(posx,posy,wid,ht);
posx = posx + xd;
posy = posy + yd;
if (posx>width) {
xd = -xd;}
if (posy>height) {
yd = -yd;}
if (posx<0) {
xd = -xd;}
if (posy<0) {
yd = -yd;}
}
void smiley(int x,int y,int w,int h) {
fill(255,255,255); //white
ellipse(x,y,w,h);
noFill();
arc(x,y,w/2,h/2,.25*PI,PI*.75);
fill(0,0,0); //black
ellipse(x-w*.25,y-h*.25,w/10,h/10);
ellipse(x+w*.25,y-h*.25,w/10,h/10);
}
All I want to do is take this and make the smiley ball bounce up and down only. Also, I have to add 2 more balls, so I would have 3 balls bouncing up and down.
Thank you in advance for any help!
void setup() {
size(500,500);
frameRate(15);
}
int posx;
int posy;
int xd = 10;
int yd = 20;
int wid =50;
int ht = 80;
void draw() {
background(#0024FF);
smiley(posx,posy,wid,ht);
posx = posx + xd;
posy = posy + yd;
if (posx>width) {
xd = -xd;}
if (posy>height) {
yd = -yd;}
if (posx<0) {
xd = -xd;}
if (posy<0) {
yd = -yd;}
}
void smiley(int x,int y,int w,int h) {
fill(255,255,255); //white
ellipse(x,y,w,h);
noFill();
arc(x,y,w/2,h/2,.25*PI,PI*.75);
fill(0,0,0); //black
ellipse(x-w*.25,y-h*.25,w/10,h/10);
ellipse(x+w*.25,y-h*.25,w/10,h/10);
}
1