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

Click to download the  bonus!

Click to download the 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, Create and Step.

Create: The Create event prepares the object_Log instances to zoom off at a speed of 50 moving up and to the right.

object_log-create-event

Step: 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 Create, Key Up - Left and Key - Up Right.

Create: The only thing that happens during this event is the built-in score variable is set to zero.

object_maintree-create-event

Key Up - Left: 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

Key Up - Right: The code and explanation for this event is exactly the same as the Key Up- Left event.

object_Player

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

Collision with object_Branch: 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

Key Down - Left: This code which side of the tree the player is standing on and then it spawns an instance of object_Axe in the appropriate place.

object_player-key-down-left-event

Key Down - Right: The code and explanation for this event will be the same as the previous event.

Key Up - Left: The code in this event positions the object_Player on the left-hand side and scales its sprite so it is facing in the correct direction.

object_player-key-up-left-event

Key Up - Right: The code and explanation for this event is the same as the previous event with the exception that horizontal scaling is set to 1 and the x variable/coordinate is set to 1165.

object_Axe

Key Up - Left: This simply destroys (despawns) the instance.

object_axe-key-up-left-event

Key Up - Right: This event contains the same code as the previous event.

object_Bee

Create: This code sets object_Bee up ready to fly with a random speed and heading to the left of the screen.

object_bee-create-event

Step: 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

Key Up - Left: 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 switch block and the three case 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

Key Up - Right: This event does exactly the same as the previous event.

object_Cloud

Create: 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

Step: The Step 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

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

object_score-draw-event

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

object_score-key-press-backspace-event

object_Message

Draw: This draws a message to the screen at coordinates 50, 700.

object_message-draw-event

Key Press - Enter: This causes the game to transition to the screen where the game can be played.

object_message-key-press-enter-event

Key Press- Escape: This causes the Escape key to quit the game.

object_message-key-press-escape-event

object_Timebar

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

object_timebar-create-event

Step: This code subtracts 1/30th from the timeReamining 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

Draw: 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

Thanks

Thanks for taking a look at this tutorial, please leave a comment or ask questions.