We are going to create your own game we will call it Fruit Drop. The objective is to throw fruit at the bad guys to keep them from getting to your Tree.
Timmy
Sally
Kim
Gus
Doc
Henry
Stan
Jule
Misty
Mel
Curlz
Moho
Mystro
Prince
Star
Wiz
Zed
Jade
Badge
Knight
Prof
STEP 1
Right Click on the image and save the one you want to use for your character.
Right Click on Sprite Folder the click Create then Sprite now Import your characters sprite.
Name the sprite sPlayer
STEP 2
Right Click on Object Folder then click Create then Object
Select the sPlayer sprite and name the object oPlayer
STEP 3 Make Character Move
Now we need to make your character move using the arrow keys
Double Click on your characters object to open it
Click on Add Event Key Down Left
When you you add this first Event it will ask you what kind of coding you want to do Choose GML Visual and click: "Don't ask again for this project."
In the Key Down Left Event add a Set Direction Fixed and select Left
Now Add a Set Speed and type in 4 for the speed make sure relative is NOT checked
Repeat for Key Down Right
Add a Key Down No Key event
Drag in Set Speed Action and type 0 for speed
STEP 4 Create Room
Click on the Rooms folder and select Room1.
Drag you persons object into the middle of your room.
Now run the game to test the movement of your character
STEP 5 Walls
Now we need to make walls for your room
Save the image of the wall type you want for your first room.
Wall
Wall 2
Wall 3
Wall 4
Wood
Wood 2
Rock
STEP 6 CREATE WALL OBJECT
Right Click on Sprite Folder the click Create then Sprite now Import your Wall sprite.
Name the sprite sWall
Create Object for you wall and name it oWall
Note: the wall object needs to have solid checked
Open your room and place walls around the perimeter of your room
STEP 7
Stop your character from moving through walls
Now you need to stop your character from being able to walk through walls
Open your character object
Add a Collision Event with the wall
Drag in a Set Speed action and select 0 for speed
Test your game
STEP 8
Make Fruit Object
Now we need to make a fruit object so you can drop it on the enemy
Lets start with the apple
Right Click on Sprite Folder the click Create then Sprite now Import your Apple sprite.
Name the sprite sApple
Create Object for Apple
Select the apple sprite and name the object oApple
We want the apple to be destroyed when it goes outside the room.
Now add a Other Event for Outside Room
Add a Destroy Instance
Now Add a Create Event to your Apple
Add Set Direction Fixed Action and select Down
Add a Set Speed > Direction > Speed = 15
STEP 9
Make your Character Drop Fruit
We need to make your character drop the fruit
Open character object
Create a Key Press Event
Select the Space key
Drag the Create Instance Action into the event and select the apple object check relative fir X and Y
Test your game
Ghost
Skeleton
Statue
Snake
Bat
Spider
Yeti
STEP 10
Make Enemy Move
Now we have to make enemies that are trying to get you
Lets start with the Ghost
Add Sprite for Ghost
Name the sprite sGhost
Create Object for Ghost
Select the ghost sprite and name the object oGhost
We want the Ghost to rise slowly up when it is created
Add a Create Event to the Ghost
Drag in an Add Motion Action > Direction = 90 > Speed = .5
STEP 11
Make Apple Hurt Enemy
We want the Ghost to rise slowly up when it is created and be destroyed when the fruit hits it.
Add a Collision Event with the Apple
Drag the Set Global Variable Action and give it 10 points and check relative.
Drag destroy instance of self into the action
Drag another destroy instance action and select "other" this will destroy the apple which is the other object involved in the collision
Put a ghost or 2 near the bottom of the screen and test game
STEP 12
Characters lives and score variables
Double Click on your player to open it
Add a Game Start Event found in the "Other" section
Add a Set Global Variable name it global.LIVES give it a value of 3 don't check relative
Add a Set Global Variable name it global.POINTS give it a value of 0 don't check relative
STEP 13
Enemy Hurts You
We want the enemy to hurt you so you will lose a life and the game will start over if you lose all your lives
Now make the monster take away a life from your character
Open your characters object add a collision event with the Ghost and drag a Set Global Variable name global.LIVES actions give it a value of -1 and check relative
Now drag in a restart room action into the collision event
STEP 14
Restart Game if you run out of lives
Open your oPlayer object by double clicking on it
Open the collision with the Ghost object
Add a If Variable action name global.LIVES select Less or Equal value = 0
Attach a Restart Game action to the If then statement Make sure the restart room action is attached to the side as show not just underneath
STEP 15
Add code to display points and lives
Open your oPlayer object by double clicking on it
Now Add a Draw Event
Add Draw Self
Now Add a Draw GUI Event
Add a Draw Value value = global.POINTS
Set Caption to "Score: "
Add a Draw Value value = global.LIVES
Set Caption to "Lives: "
Set the x to 100 to move it 100 pixels to the right of the Points
STEP 16
Second Room
Right click on the Rooms folder and select Create Room.
Select your character object and place it in your room.
Draw walls around the perimeter of room except for the top
We need to create a platform for your character to stand on Use the Wall object
Hint if you hold down Shift + Alt you can drag to add walls making it much faster to create room
STEP 17 Make Door
Moving from One Room to another
We have to make an object that will make you go to the next room once you have completed the previous level. To do this we will make a magic door appear once you have defeated all the monsters in the level lets create a door object you can draw your own door sprite or use this door
Open your players object
Now we have to think about what your character has to do to finish level 1
In my case I have to hit all the ghosts with apples once I have done this I will go to level 2
Add a Step Step event
Add a If Instance Exists action
Select oGhost as the object and click Not
Add a Create Instance Action select the oDoor object and change the X to 64 and the Y to 64
Make sure the Create Instance Action is attached to the side like shown
If your door is not in the correct place it might be hidden under your players platform so adjust the Y value to make it be just above the platform
STEP 18
Ladders
We want 3 things different in the second room
Room with ladders for monsters to climb
Second type of monster
A Tree that gives you special fruit
Lets start with a Ladder
Save the ladder sprites by right clicking and save image as
Name the sprite sLadder
Create a ladder Object
Select the ladder sprite and name the object oLadder
Now place oLadder in your room 2 to form a ladder leading from the bottom of your screen to the top.
You can edit the size of your ladders to make them 32px x 32px
STEP 19
Collision Objects
We need to make some collision objects to make monster change their direction when they collide with them
Save these for sprites and turn them into four different objects
Make all these objects invisible by un-checking visible.
Add a Up block into room two on the bottom of the ladder and a right arrow to the top of the ladder
STEP 20
Second Monster Movement
Lets make the Skeleton
Name the sprite sSkeleton
Select the skeleton sprite and name the object oSkeleton
We want the Skeleton to walk until it finds a ladder then start to climb the ladder and be destroyed when it goes outside the room or if the fruit hits it.
Add a Create Event to the Skeleton
Add a Assign Variable action name it run give it a value of 2
Drag in a Set Direction Fixed action and select the left direction
Drag in a Set Speed select run for its speed
Now add an Outside room event to the skeleton
Drag in a Set Global Variable action give it a value of -1 and check relative so that the skeleton will take away a life from your player if you fail to hit it with an Apple
We also need to check if your run out of lives so that the game will restart if you let too many monsters escape
Add a If Variable action check the global.LIVES variable if it is equal to 0
The attach a Restart Game action make sure it is to the right as shown
You can add this same code to your Ghost to make it do the same thing
STEP 21
Skeleton is hurt by Apple
We want the apples to hurt the skeletons
Add a Collision Event with the Apple
Drag the Set Global Variable Action and give it 25 points and check relative.
Drag destroy instance of self into the action
Drag another destroy instance action and select "other" this will destroy the apple which is the other object involved in the collision
STEP 22
Skeleton moves with arrow objects
Add a Collision Event with the oUp object
Drag in a Set Direction Fixed action and select the up direction
Drag in a Set Speed select run for its speed
Repeat the steps for the right left and down objects
Add direction objects on the left and right walls to keep the skeleton from running outside the room
Add 4 or 5 skeletons to your room and test your game
STEP 23 Create Door if no Skeletons
Open Characters Step Event
Add a If Instance Exists action to the Left of the first If Instance action
Select oSkeleton as the object and click Not
This will check to make sure their are no skeletons or ghosts in the room before we create a door to move to next room
Ghost
Moves up slowly
Skeleton
Can Climb ladders
Statue
Can break through walls
Snake
Can climb ladders and walls
Bat
fly's around
Spider
can climb on walls
Yeti
Throw snowballs can't climb
STEP 24 More Monsters the Snake
Lets make our third monster. The snake will be a fast moving vine climber. They are deadly to your trees and to you. They can be defeated just like skeletons and ghosts.
I will introduce you to a time saving concept called inheriting events and actions from a Parent object.
We took a lot of time to code the skeleton object. The snake will do all the same actions as the skeleton except it will be faster. So I will show you how to do this.
Save the snake sprite and create and sprite and object for it
Name the sprite sSnake
Select the snake sprite and name the object oSnake
Now we will select the skeleton as the parent for the snake
Now the snake will do everything the skeletons do. This saves lots of time.
We want the skeleton to be faster so we will change one thing its run variable to make it faster than the skeleton
STEP 25 Customize the Snake
Add a Create event
Add a Assign Variable action name it run give it a value of 6
Drag in a Set Direction Fixed action and select the left direction
Drag in a Set Speed select run for its speed
Now make a room for the snake maybe add the vines for ladders and walls like show below
STEP 26 Snake Room
Create your Snake room with vines for ladders be sure that the arrows will make your snakes climb the vines as shown You can also adjust the speed of the snake if it is too fast with the run variable in the create event
STEP 27 Statue
The Statue will be a slow moving monster that likes to hide behind walls.
Create Sprite and Object for the statue
Name the sprite sStatue
Select the statue sprite and name the object oStatue
Now we will select the skeleton as the parent for the statue just like the snake
We do want the statue to be slower so we will change one thing.
Add a Create event
Add a Set Variable action name it run give it a value of 1.5
Drag in a Move fixed action and select the right and left direction speed of run relative NOT checked
STEP 28 Bat
The Bat will be a fast moving cave dwelling monster that likes to move eratically. For this movement we will use a Path
Create Sprite and Object for the Bat
Name the sprite sBat
Select the bat sprite and name the object oBat
Now we will select the skeleton as the parent for the bat just like the snake
Now we need to create a Path before we do this lets make a new room use these sprites to make the cave room.
After your room is created now we can make the path that the bats will follow.
Right Click on the Paths folder and select Create Path
Click on the Room to Show icon select the Cave room you just created this will overlay the screen with the room so you know where to place the dots.
Now start on the bottom of the room where you want the bats to spawn and create a path that zig zags around the room until it reaches your level at the top.
Save the path as path_cave.
Now open your bat object Add a Create event
Add a Set Path and select path_cave
Now add these settings for your set path
Put one bat in your room and test the game.
Put one bat in your room and test the game.
Spider
The spider will move at random speeds so we will use that concept with these 8 legged terrors.
Click on Add Sprite Icon click load sprite
Name the sprite sSpider
Click on the Create Object Icon
Select the spider sprite and name the object oSpider
Now we will select the skeleton as the parent for the spider just like the snake
We want the spider to have a random speed.
Add a Create event
Add a Set Variable action name it run give it a value of random_range(1,8)
Drag in a Move fixed action and select the right and left direction speed of run relative NOT checked
Yeti the final Boss
The Yeti is the most fearsome creature in the game. This denizen of the Himalayas is sometimes called the abominable snowman. He cannot be stopped by a single apple it will take many. He will also fight back throwing snowballs at you with such force and accuracy that you will be astonished.
Snow balls
First we need to create the snowball object
Click on Add Sprite Icon click load sprite
Name the sprite sSnowball
Click on the Create Object Icon
Select the snowball sprite and name the object oSnowball
Add a Create event
Add a Move Towards action
Give it these settings so it will go toward your character
Now add a Other Event for Outside Room
Add a Destroy Instance and select self
Open your characters object and add
Now make the snowball take away a life from your character
Open your characters object add a collision event with the snowball
Add a set lives into the actions give it a value of -1 and check relative
Now drag in a restart room action into the collision event
Boss Level
Now lets make the boss level we will use a tileset for this room it makes it much easier to design rooms without having to make objects.
Save this tileset
Right Click on the background folder and select this as the background save it as bgIce.
Click on use as tile set
Set tile width to 8 and tile height to 8
Now create a new room and name it rm_yeti
Go to the tiles tab
Hold down the shift key as you select the part of the tile set you would like to use for your room
Once it is selected click on the spot in the room where you want that graphic
Design the rest of your room.
Boss throws snowballs
Let make your boss throw the snow balls this is very easy.
Yeti
Click on Add Sprite Icon click load sprite
Name the sprite sYeti
Click on the Create Object Icon
Select the yeti sprite and name the object oYeti
Add a Create event
Add a Set Variable action name it run give it a value of 2
Drag in a Move fixed action and select the right and left direction speed of run relative NOT checked
Now select the skeleton as the parent for the yeti just like the other monsters
Add a Step step event
Add a Test Chance
Select 30 sides this will average about 1 second since there are 30 steps per second
Drag the Create Instance Action into the event and select the snowball object check relative
Test your game it should throw snowball intermittently at you
Boss Health
Now we want your boss to have health so it takes more apples to bring him down.
Open your Yeti object and go to the Create event
Add a Set Health action give it 100 do not check relative
Now add a collision event with the apple
Add a Set Health action give it a value of -3 check relative
Drag destroy instance of other into the action
Add a check healthselect smaller than 0
Drag in a Start Block
Drag the Set Score Action and give it 1000 points and check relative.
Add a sleep for 1000 milliseconds
Add a Display Message type in "You have defeated the mighty Yeti"
Add a Show High Score
Add a Restart Game
Draw Health Bar
Add a second event Draw
Add a Draw Sprite action select the yeti sprite and check relative
Add a Draw Health actiongive it the settings below