Game 1: Bouncing Ball

The bouncing ball game will provide the basics of using sprites, sounds, objects and rooms.

Game 1: Instructions

Bounce Code

///Bounce against walls
//Back up ball before collision
x=xprevious;
y=yprevious;
var corner = true;
//Bounce for horizontal collision
if(place_meeting(x + hspeed,y,obj_wall))
{
hspeed = -hspeed;
corner = false;
}
//Bounce for vertical collision
if(place_meeting(x,y + vspeed,obj_wall))
{
vspeed = -vspeed;
corner = false;
}
//deal with corner case
if (corner == true)
{
hspeed = -hspeed;
vspeed = -vspeed;
}