Urgent help with the code
in
Programming Questions
•
2 years ago
This is the code::
int x,y;
int xspeed;
int yspeed;
int rectx;
int recty;
void setup()
{
size(500,500);
x=100;
y=100;
xspeed=5;
yspeed=4;
rectx=10;
recty=mouseY;
}
void draw()
{
background(255);
fill(255,0,0);
ellipse(x,y,50,50);
x=x+xspeed;
y=y+yspeed;
if(x>width)
{
xspeed=-abs(xspeed);
}
if(y>height)
{
yspeed=-abs(yspeed);
}
if(y<=0)
{
yspeed=abs(yspeed);
}
fill(0,0,255);
stroke(0,255,0);
rect(rectx,mouseY,50,100);
if(x<=rectx)
{
xspeed=abs(xspeed);
}
}
im trying to make the ball bounce off the paddle you control and get faster every time it bounces. I already made it bounce the other 3 walls. i messed up the part where the ball bounces of the paddle and i did not do the part where the ball gets faster every time it bounces of the paddle
int x,y;
int xspeed;
int yspeed;
int rectx;
int recty;
void setup()
{
size(500,500);
x=100;
y=100;
xspeed=5;
yspeed=4;
rectx=10;
recty=mouseY;
}
void draw()
{
background(255);
fill(255,0,0);
ellipse(x,y,50,50);
x=x+xspeed;
y=y+yspeed;
if(x>width)
{
xspeed=-abs(xspeed);
}
if(y>height)
{
yspeed=-abs(yspeed);
}
if(y<=0)
{
yspeed=abs(yspeed);
}
fill(0,0,255);
stroke(0,255,0);
rect(rectx,mouseY,50,100);
if(x<=rectx)
{
xspeed=abs(xspeed);
}
}
im trying to make the ball bounce off the paddle you control and get faster every time it bounces. I already made it bounce the other 3 walls. i messed up the part where the ball bounces of the paddle and i did not do the part where the ball gets faster every time it bounces of the paddle
1
