Problem: Do it yourself: make one of pong, soccer, sokobahn or space invaders.
Solution: For obj_ball
Sprite: spr_ball
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Step Event:
(When the ball leaves the room, it will be destroyed. A new ball will then be created in the centre of the room.)
if expression x<0 is true
if expression x>608 is true
destroy the instance
create instance of object obj_ball at position (304,224)
Collision Event with object obj_paddle2:
(If the ball hits the second paddle, it will bounce off of it.)
bounce not precisely against all objects
Collision Event with object obj_wall:
(If the ball hits the walls, it will bounce off of them.)
bounce not precisely against all objects
Collison Event with object obj_paddle1:
(If the ball hits the first paddle, it will bounce off of it.)
bounce not precisely against all objects
Other Event: Outside Room:
(When the ball leaves to room, it will jump to its original position and remain stationary.)
jump to start position
start moving in directions 000010000 with speed set to 0
Key Press Event for <Space> Key:
(After the ball is placed in the centre of the room, the space bar can be pressed, enabling it to move in a random direction at a set speed of 15.)
set speed to 15 and direction to 45+random(360)
Solution: For obj_paddle1
Sprite: spr_paddle1
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Collision Event with object obj_wall:
(If the ball hits the paddle, it will bounce off of it.)
bounce not precisely against all objects
Keyboard Event for A-key Key:
(Enables the paddle to move in an upwards direction at a set speed of 8 when the A-key is pressed.)
start moving in directions 000000010 with speed set to 8
Keyboard Event for Z-key Key:
(Enables the paddle to move in a downwards direction at a set speed of 8 when the Z-key is pressed.)
start moving in directions 010000000 with speed set to 8
Solution: For obj_paddle2
Sprite: spr_paddle2
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Collision Event with object obj_wall:
(If the ball hits the paddle, it will bounce off of it.)
bounce not precisely against all objects
Keyboard Event for <Up> Key:
(Enables the paddle to move in an upwards direction at a set speed of 8 when the up arrow key is pressed.)
start moving in directions 000000010 with speed set to 8
Keyboard Event for <Down> Key:
(Enables the paddle to move in a downwards direction at a set speed of 8 when the down arrow key is pressed.)
start moving in directions 010000000 with speed set to 8
Solution: For obj_wall
Sprite: spr_wall
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
