GameMaker
Version 8.1
1 –
Creating a ring and diamond object
·
Download
and unzip the resources.
·
Create
a ring sprite.
·
Create
a diamond sprite.
·
Create
a ring object using the ring sprite.
·
Create
a diamond object using the diamond sprite.
2 –
Creating the bear object
·
Create a bear sprite.
·
Create a bear object using the
bear sprite.
·
Inside your bear object, add a
Keyboard Event <LEFT>.
·
Inside the above event, add a
Move Fixed action (Click Left arrow, Speed=4)
·
Add three other events and
corresponding actions to all for movement in all directions.
3 –
Creating a room
- Create a new room.
- Add one bear object and a few
rings and diamonds to it.
Save and
test the game. The bear should move
with the arrow keys.
4 – Creating the data tracking
object.
· Create a new object. Name it obj_data. No sprite.
· In obj_data, add a Create event.
· Inside Create, add a Set
Variable action (control tab).
o Variable name: ring_count
o Value: 0
· Inside Create, add another Set
Variable action (control tab).
o Variable name: diamond_count
o Value: 0
· Still in obj_data, add a Draw
event.
· Inside Draw, add a Draw Text
event (draw tab).
o Text: "Diamonds: " +
string(diamond_count)
o x: 0
o y: 0
· Still inside Draw, add another
Draw Text event (draw tab).
o Text: "Rings: " +
string(ring_count)
o x: 0
o y: 20
5 – Adding object to the room
· Add an instance of obj_data to
the room.
Save and test the game. You should now see the ring and diamond
counts (both zero). Note that you
cannot pick any of them up yet.
6 – Collisions
with diamonds
· Inside the bear object, add a
Collision event with diamond objects.
· Inside the Collision event, add
a Destroy Instance action.
o Apply to Other.
· Also inside the Collision event,
add a Set Variable action.
o Variable: obj_data.diamond_count
o Value: 1
o Relative: Check it!
NOTE: The above will increase the diamond_count variable
that is in the obj_data object by one.
Save and test the game. You can now pick up diamonds and the
diamond count should show at the top.
7 – Collisions
with rings
· Inside the bear object, add a
Collision event with ring objects.
· Inside the Collision event, add
a Destroy Instance action.
o Apply to Other.
· Also inside the Collision event,
add a Set Variable action.
o Variable: obj_data.ring_count
o Value: 1
o Relative: Check it!
NOTE: The above will increase the ring_count variable
that is in the obj_data object by one.
Save and test the game. You can now pick up rings and the ring
count should show at the top.
Note: You can use this method over multiple rooms by doing the following:
· Inside the obj_data object,
place a checkmark beside Persistent.
This will make it so that your object persists to exist in future rooms
after it was created in one room and it won’t run its CREATE event for each
room. Also, there is no need to add
that object to every room.
Done!
|