Keep ball bouncing

O

OfficialVreesie

Guest
Hi all, I have a problem.
I created this game where I have a ball that can bounce against the walls, but I also want to keep the ball bouncing for a minimum speed, so the ball can go faster than that, but it must be bouncing a bit!

Here is my step event code:
//apply gravity
yspd += grav;
//collide on x-axis
if place_meeting(x+xspd,y,obj_block1)
{
while !place_meeting(x+sign(xspd),y,obj_block1)
{
x += sign(xspd);
}

//bounce
xspd *= -bouncedecay;
}
//collide on y-axis
if place_meeting(x,y+yspd,obj_block1)
{
while !place_meeting(x,y+sign(yspd),obj_block1)
{
y += sign(yspd);
}

//bounce
yspd *= -bouncedecay;
}
//Update positions
x += xspd;
y += yspd;

Now I already tried to keep yspd > 10 and yspd < -10, but that causes the ball to freeze.

How can I do this?
 
Top