Lets Buiding a Timberman Game in GameMaker Studio 2

In this tutorial, we will quickly build a Timberman clone for PC/Mac using GameMaker Studio 2. This is my first ever video tutorial and I hope to make future video tutorials more polished. Feedback in the comments section of this article or on YouTube is appreciated. The tutorial is supported by comprehensive screenshots, notes, and free asset download bundle. Timberman is a highly addictive game with lots of features like unlockable skins and online multiplayer challenges. If you have never played it then I definitely recommend you do. Timberman is free (ad supported) on mobile and last time I checked it was just a dollar on Steam for the desktop version.

Here is another image of the game that we will build.

building-timberman-with-gamemaker-studio-2-gameplay

Here is the actual video (or view it directly on YouTube)

The download bundle

Here is what you get:

timberman-sprites

You also get three sound effects used in the game.

Download by clicking the button below and unzip the contents. Add the two folders which contain all the images and sound effects into the same folder where you created the Timberman project in GameMaker Studio 2.

timberman-download-bundle

The code

What follows is just a brief explanation and a screenshot of the GameMaker Studio 2 code. For a full discussion please watch the video. Here are the images of the code:

object_Log

This object has code in two events,

and

.

: The

event prepares the

instances to zoom off at a speed of

moving up and to the right.

object_log-create-event

: The Step event detects when the log leaves the screen by constantly checking whether x > 1920. When it is the instance is destroyed.

object_log-step-event

 

object_MainTree

This object has three events. They are

,

and

.

: The only thing that happens during this event is the built-in

variable is set to zero.

object_maintree-create-event

: When the player releases the left arrow key, this code will spawn a log and play the chopping sound effect. Next, it will add ten points to the player’s score and add .15 of a second on to the time the player has left. Note that once the log is spawned, the code in the log instance takes over what will happen to it.

object_maintree-keyup-left-event

: The code and explanation for this event is exactly the same as the

event.

object_Player

This object has the most events with code in them. None of them are complicated, however.

: The code checks if the branch that has been collided with is visible and if it is it plays a death sound and goes back to the start screen.

object_player-collision-with-branch-event

: This code which side of the tree the player is standing on and then it spawns an instance of

in the appropriate place.

object_player-key-down-left-event

: The code and explanation for this event will be the same as the previous event.

: The code in this event positions the

on the left-hand side and scales its sprite so it is facing in the correct direction.

object_player-key-up-left-event

: The code and explanation for this event is the same as the previous event with the exception that horizontal scaling is set to

and the

variable/coordinate is set to

.

object_Axe

: This simply destroys (despawns) the instance.

object_axe-key-up-left-event

: This event contains the same code as the previous event.

object_Bee

: This code sets

up ready to fly with a random speed and heading to the left of the screen.

object_bee-create-event

: This code checks each and every frame(step) whether the bee has left the left of the screen and if it has it spawns it back on the right with a random height and speed.

object_bee-step-event

 

0bject_Branch

: This code is discussed in great detail in the video so if it is causing you trouble be sure to take a look. The code checks if a branch has arrived at the lowest point of the tree and if it has it respawns it at the top of the tree. The

block and the three

statements (in conjunction with the random number generator) determine whether the branch is respawned on the left, the right or not at all (invisible). After all this, the code moves the branch 150 pixels down.

object_branch_key-up-left-event

: This event does exactly the same as the previous event.

object_Cloud

: This event sets the speed of a cloud instance to somewhere between 1 and 6. Then sets it heading off to the right-hand side of the screen.

object_cloud-create-event

: The

event checks whether a cloud has left the screen and then gives it a new random height and speed. Just like the bee but with different values and in the opposite direction.

object_cloud-step-event

object_Score

: This draws the text and the score to the top left-hand corner of the screen.

object_score-draw-event

: This transitions to the starting screen when the player presses the Backspace key.

object_score-key-press-backspace-event

object_Message

: This draws a message to the screen at coordinates

,

.

object_message-draw-event

: This causes the game to transition to the screen where the game can be played.

object_message-key-press-enter-event

: This causes the Escape key to quit the game.

object_message-key-press-escape-event

object_Timebar

: This causes a list of variables to be created when the instance is first created.

object_timebar-create-event

: This code subtracts 1/30th from the

variable on each step of the game. If time runs out a sound effect is played and the game transitions to the start screen.

object_timebar-step-event

: Finally, this event draws a time bar (rectangle) to the screen with an appropriate width to represent how much time the player has left.

object_timebar-draw-event

Leave A Reply

Your email address will not be published.