Skills Task Twelve

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>

Leave a Comment

Filed under Skills Tasks

Skills Task Eleven

Problem: Push a rock.

Solution: For obj_ghost
Sprite: spr_ghost
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Keyboard Event for <Right> Key:
(Enables the ghost to move one position right when the right arrow key is pressed.) 
move relative to position (4,0)

Solution: For obj_rock
Sprite: spr_rock
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Alarm Event for alarm 0:
(Makes the rock a stationary object when not being pushed.)
start moving in directions 000010000 with speed set to 0

Collision Event with object obj_ghost:
(Enables the rock to be pushed to the right by the ghost providing the space is not already occupied. When the rock is pushed, it will once again become a stationary object.)
if expression obj_ghost.direction=0 is true
if position (24,0) is collision free for Only solid objects
move relative to position (2,0)
start moving in directions 000001000 with speed set to 2
set Alarm 0 to 1.5 

Leave a Comment

Filed under Skills Tasks

Skills Task Ten

Problem: A character jumps up off a platform, and returns under the influence of gravity – you cannot jump in midair.

Solution: For obj_ball
Sprite: spr_ball
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Step Event:
(Enables the ball to jump up providing the space is not occupied and return under the influence of gravity. If the ball is not in the jumping act, there is no gravity, enabling it to move side to side.) 
if expression place_empty(x,y+1) is true
set the gravity to 1 in direction 270
else
set the gravity to 0 in direction 0

Collision Event with object obj_wall:
(If the ball hits the walls, it will cease to move in an upward direction.)
set the vertical speed to 0

Keyboard Event for <Space> Key:
(When the space bar is pressed, the ball will jump providing the space above is not occupied. When the ball reaches the peak of its jump, it will fall back down to a space that is occupied.)
if relative position (0,1) is not collision free for Only solid objects
set the vertical speed to -15

Keyboard Event for <Left> Key:
(Enables the ball to move one position left when the left arrow key is pressed.)
move relative to position (-4,0)

Keyboard Event for <Right> Key:
(Enables the ball to move one position right when the right arrow key is pressed.)
move relative to position (4,0)

Solution: For obj_wall
Sprite: spr_wall
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Leave a Comment

Filed under Skills Tasks

Skills Task Nine

Problem: A character fires a bullet and has to wait one second before being able to fire the next bullet.

Solution: For obj_plane
Sprite: spr_plane
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Create Event:
(Enables the plane to fire 1 bullet.) 
set variable canshoot to 1

Alarm Event for alarm 0:
(Enables the plane to fire 1 bullet per second.) 
set variable canshoot to 1

Key Press Event for <Space> Key:
(Places a bullet at the position of the plane and allows it to be fired. When the bullet is fired, there must be a one second delay before the next one can be fired.)
if canshoot is equal to 1
create instance of object obj_bullet at relative position (0,0)
set variable canshoot to 0
set Alarm 0 to 30

Key Press Event for <Left> Key:
(Enables the plane to move one position to the left when the left arrow key is pressed.)
move relative to position (-32,0)

Key Press Event for <Right> Key:
(Enables the plane to move one position to the right when the right arrow key is pressed.)
move to relative postion (32,0)

Solution: For obj_bullet
Sprite: spr_bullet
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Create Event:
(Enables the bullet to move in an upwards direction at a set speed of 8.)
start moving in directions 000000010 with speed set to 8

Leave a Comment

Filed under Skills Tasks

Skills Task Eight

Problem: You have to hit a character 3 time with a bullet before it dies.

Solution: For obj_plane
Sprite: spr_plane
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Key Press Event for <Space> Key:
(Places a bullet to be placed at the position filled by the plane and enables it to be fired in an upward direction at a set speed of 12.)
if sprite_index is equal to obj_plane
create instance of object obj_bullet at relative position (1,1) with speed 12 in direction 90

Key Press Event for <Left> Key:
(Enables the plane to move one position to the left when the left arrow key is pressed.)
move to relative position (-32,0)

Key Press Event for <Right> Key:
(Enables the plane to move one position to the right when the right arrow key is pressed.)
move to relative position (32,0)

Solution: For obj_bullet
Sprite: spr_bullet
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Create Event:
(Places a bullet at the position of the plane.)
move to position (obj_plane.x,obj_plane.y)

Collision Event with object obj_enemy:
(When a bullet hits the plane, the bullet is destroyed.)
destroy the instance

Solution: For obj_enemy
Sprite: spr_enemy
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Create Event:
(Gives the enemy 3 lives before it is destroyed.) 
set the number of lives to 3

Collision Event with object obj_bullet:
(When a bullet hits the enemy, one of its lives is taken away and the bullet is destroyed. After the enemy has no longer got any lives, an explosion occurs at its original position.)
set the number of lives relative to -1
for other object: destroy the instance
if lives are equal to 0
change the instance into object obj_explosion, yes performing events

Solution: For obj_explosion
Sprite: spr_explosion
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Collision Event with object obj_bullet:
(When the bullet hits the enemy, the bullet is destroyed.)
for all obj_explosion: destroy the instance

Other Event: Animation End:
(After the explosion is finished, it is destroyed.)
destroy the instance

Leave a Comment

Filed under Skills Tasks

Skills Task Seven

Problem: Make a timer which counts up or down how much time is left to play.

Solution: For obj_timer
Sprite: <no sprite>
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Create Event:
(Sets the timer to 10 seconds and enables it to be played in the room at the proper speed.)
set variable mytime to 10
set Alarm 0 to room_speed

Alarm Event for alarm 0:
(Takes 1 second off of the timer at the proper speed in the room.)
set variable mytime relative to -1
set Alarm 0 to room_speed

Step Event:
(If the timer reaches 0 seconds, it is destroyed and the demonstration is ended automatically.)
if expression mytime<0 is true
create instance of object obj_timer at position (0,0)
destroy the instance
end the game

Draw Event:
(Enables the timer to be displayed in the top-left hand corner of the room.)
at position (0,0) draw text: ‘time=’+string(mytime)

Leave a Comment

Filed under Skills Tasks

Skills Task Six

Problem: A ball goes through a goal and the score goes up by one… the score does not go up if the ball misses the goal.

Solution: For obj_ball
Sprite: spr_ball
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Step Event:
(Adds 1 to the score when the ball moves through the goal at the top of the screen. When the ball leaves the screen, it is destroyed and a new ball is placed in the centre on the room.)
if expression y<0 is ture
set the score relative to 1
destroy the instance
create instance of object obj_ball at position (304,224)

Collision Event with object obj_wall:
(When the ball hits the wall, the ball is destroyed. A new ball is placed in the centre of the screen.)
destroy the instance
create instance of object obj_ball at position (304,224)

Other Event: Outside Room:
(When the ball leaves the room, a new ball is placed in the centre of the screen. The new ball does not move after being regenerated.)
move to position (304,224)
start moving in directions 000010000 with speed set to 0

Key Press Event for <Space> Key:
(Enables the ball to move in an upwards but random direction at a set speed of 10 when the space bar is pressed.)
set speed to 10 and direction to 45+random(90)

Solution: For obj_wall
Sprite: spr_wall
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>

Leave a Comment

Filed under Skills Tasks