Game Development Reference
In-Depth Information
■
Tip
Don't forget to save your work regularly by clicking on the blue disk icon on the main toolbar.
Platform Objects
It's difficult to play a platform game without any platforms, so we'll get these made and out of the
way first. We'll start by creating
obj_platform
, which is probably the most important object in the
game—despite having no events, actions, or even a sprite. This is because it's going to be the
parent object
of all other platforms. Hopefully, you'll have come across
parent
objects
before, but
one of the things they allow you to do is group together similar kinds of objects so that they all
behave in the same way. We only create three different platform objects in this example
(
obj_rock_begin
,
obj_rock_middle
,
obj_rock_end
), but an average platform game would have
many different kinds of platforms, so it's really useful to be able to treat them as a group. Most
significantly, making
obj_platform
the
parent object
of these three platforms will mean that we
can test for collisions between Fishpod and
obj_platform
and this will automatically include
collisions with
obj_rock_begin
,
obj_rock_middle
,
and
obj_rock_end
as well. Continue by following
the next set of steps and you'll see how all this comes together when we create the Fishpod
character later on.
Creating the Parent Platform Object
1.
Click on the
Resources
menu and select
Create Object
(you can also create objects by
right-clicking on the
Objects
folder in the resource tree, or using the blue ball button
on the toolbar).
2.
In the Object Properties form that appears, click on the
Name
field and enter
obj_platform
.
3.
Click the
OK
button on the bottom left of the form to close it. Yes we're done with this object.
Now we will create the rock platform objects, which all use
obj_platform
as their parent:
Creating the Rock Platform Objects
1.
Create a new object resource and enter the
Name
as
obj_rock_middle
.
2.
Click on the icon at the end of the
Sprite
field and a list of all the available sprites will
appear. Select the
spr_rock_middle
sprite.
3.
Click on the icon at the end of the
Parent
field and a list of all the available objects will
appear. Select the
obj_platform
object.
4.
Click the
OK
button on the bottom left of the form to close it.
5.
Repeat steps 1-4 for
obj_rock_begin
and
obj_rock_end
, using
spr_rock_begin
and
spr_rock_end
, respectively.
Next we'll do something to help make the process of creating levels a little less fiddly. We
want it to be possible to create rock platforms of any length, but they always need to begin with
an
obj_rock_begin
and end with an
obj_rock_end
. That will make positioning and repositioning
platforms in the room editor a bit of a chore—particularly when trying to tweak level designs.
Therefore, we'll automate the process by making every
obj_rock_middle
automatically create
begin and end platforms either side of it where necessary. That way, we only have to worry about
placing instances of the
obj_rock_middle
object in the room editor and the object events will
handle the rest for us.
Search WWH ::
Custom Search