Game 1: Bouncing Ball
The bouncing ball game will provide the basics of using sprites, sounds, objects and rooms.

Game 1: Instructions

Bounce Code

1
///Bounce against walls
2
3
//Back up ball before collision
4
x=xprevious;
5
y=yprevious;
6
var corner = true;
7
8
//Bounce for horizontal collision
9
if(place_meeting(x + hspeed, y, other))
10
{
11
hspeed = -hspeed;
12
corner = false;
13
}
14
15
//Bounce for vertical collision
16
if(place_meeting(x, y + vspeed, other))
17
{
18
vspeed = -vspeed;
19
corner = false;
20
}
21
22
//deal with corner case
23
if (corner == true)
24
{
25
hspeed = -hspeed;
26
vspeed = -vspeed;
27
}
28
29
Copied!