GAME MAKER SKILLS CHALLENGES
Techniques for randomising, shooting, destroying, following, goal scoring, timing, platform jumping and pushing
Guidelines:
You may help each other as much as you like but you must write the code for the solution you hand in. You are expected to learn so if you get the code ideas off someone else make a real effort to understand how it works
Teacher will provide hints from time to time. You can ask him questions at any time – this is helpful – but he won’t always give you the answer.
1) A ball bounces around a room and its direction is random. When the demo starts you can’t predict in which direction the ball will go. When the ball hits the walls you can’t predict in which direction the ball will go.
Hint: use the icon on the Move tab with 8 blue arrows and the random() function for both the initial Create Event and also after the ‘Bounce against objects’ action.
2) Make an animation from a strip sheet of stills.
a) one where all the slides are the same size (easier)
b) another where the slides are of varying sizes (harder)
Hint:
Sprite editor > File > Create from Strip
Sprite editor > File > Add from Strip
Hint: For slides of varying sizes start with the largest size and add the smaller sizes later and rearrange order. It can be a fiddly, tedious process!
Suitable strip sheets are astro_sheet.gif, shadow_sheet.gif, kadotsu_sheet.gif
3) A character can move left and right with arrow keys (you have to keep pressing the key for it to keep moving) and fires a single bullet forward when you press space bar. You have to release and press space bar again for more bullets. Provide information about how to play the demonstration in Game Information.
Hint to control character: Move tab > Jump to a given position (tick Relative)
Hint to create bullet: main1 tab > x: character.x;y:character.y
(substitute for character whatever your character name is)
Hint for firing a single bullet: Use Keypress Event, not Keyboard Event
4) When a bullet hits a character, the character explodes and the explosion then disappears. Provide information about how to play the demonstration in Game Information.
Hint to explode character:
Collision Event: Enemy collides with bullet
Action: main1 > Change the instance
Hint to disappear explosion:
Event > Other > Animation end
Action: main1 > Destroy the instance
5) Make one object follow another object
Hint: For the object being followed, when it leaves the room one way to get it back inside the room is:
Other Event > Outside Room
Action > Jump to a random position
Hint: For the object which is following use the
Step Event (it checks 30 times every second)
Action: move tab > Move in the direction of a point
6) 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
Hint: For the ball to score a goal
Step Event (checks 30 times per second)
Actions:
Control tab > If an expression is true
expression: y < 0 (where ever the goals are)
then, Score tab > Set the score
> Destroy the instance (otherwise score keeps going up)
main1 tab > Create a new instance at the start position
7) Make a timer which counts up or down how much time is left to play
Concept: This introduces the concept of a variable. A variable has a name, in this case mytime and a value. For any given variable the name doesn't change but the value does.
Hints:
Make an objTimer object (sprite not required)
Create Event:
set variable mytime to 10// name and initialise variable, you choose the value
set Alarm 0 to room_speed// default is 30 steps per second
Alarm Event for alarm 0:
set variable mytime relative to -1// counts down
set Alarm 0 to room_speed// or 30
Draw Event:
at position (0,0) draw text: 'time = ' + string(mytime)// convert number to string then join
Extension: Use an if statement on the Step Event to make the value of the time stop at zero.
8) You have to hit a character 3 times with a bullet before it dies
Hint: Start with Challenge 4, then add lives in the create event:
score tab > set the number of lives
Hint: Take a life off each time the bullet hits the character. Write an if statement that makes the destruction of the enemy conditional on lives being reduced to zero or less than one.
score tab > If lives is a value
9) A character fires a bullet and has to wait one second before being able to fire the next bullet
Hint: Start with problem 8 and save a version with a different name
Hint: Boolean variable, eg. call it canshoot
Create Event > set canshoot to true, or 1
When character fires bullet, then set canshoot to false or 0
At the same time set an Alarm to 1 second (30 steps by default)
When the Alarm goes off then set canshoot to true or 1
10) A character jumps up off a platform, and return under the influence of gravity – you cannot jump from midair
Hints:
a) Make characters, floor and platforms solid
b) Gravity: Set the gravity to 1 when the character is moving down and set it to zero when it is on a platform (otherwise it won't be able to move left and right)
Step Event:
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
c) When character hits platform make vertical speed = 0
d) Jumping: <Up> Key set vertical speed negative for up
To prevent jumping from mid air run a test to check whether the character is standing on a solid platform
Key Press Event for <Up> Key:
if relative position (0,1) is not collision free for Only solid objects
set the vertical speed to -15
11) Push a rock
You need to set the direction of the object that is doing the pushing. Set the direction variable for the left, right, up and down arrows. Then you can run tests (if statements) to push the rock in the correct direction conditional on whether the rock has a free place to go to.
It's best to place code the rock colliding with the pushing object (and not the other way around) because it's easier to check whether there is a place free for the rock to be pushed in a given direction.
The code is just shown for moving east
Information about object: objRock
Collision Event with object objGhost:
if expression objGhost.direction=0 is true // moving east
if relative position (24,0) is collision free for Only solid objects
move relative to position (24,0)
play sound sndBoink2; looping: false
12) Do It Yourself: Make one of, that you haven't made before:
- pong
- soccer
- sokoban
- space invaders
Bill Kerr, updated February 2006