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.
Here is the actual video (or view it directly on YouTube)
The download bundle
Here is what you get:
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.
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:
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.
Step: The Step event detects when the log leaves the screen by constantly checking whether x > 1920. When it is the instance is destroyed.
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.
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.
Key Up - Right: The code and explanation for this event is exactly the same as the Key Up- Left event.
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.
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.
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.
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.
Key Up - Left: This simply destroys (despawns) the instance.
Key Up - Right: This event contains the same code as the previous event.
Create: This code sets object_Bee up ready to fly with a random speed and heading to the left of the screen.
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.
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.
Key Up - Right: This event does exactly the same as the previous event.
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.
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.
Draw: This draws the text and the score to the top left-hand corner of the screen.
Key Press - Backspace: This transitions to the starting screen when the player presses the Backspace key.
Draw: This draws a message to the screen at coordinates 50, 700.
Key Press - Enter: This causes the game to transition to the screen where the game can be played.
Key Press- Escape: This causes the Escape key to quit the game.
Create: This causes a list of variables to be created when the instance is first created.
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.
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.
Thanks for taking a look at this tutorial, please leave a comment or ask questions.