Tutorial - Platformer

Tom Mulgrew


This tutorial uses a number of assets released under different Creative Commons licences.

Some adjustments were made to the artwork to make them easier to load into Basic4GL Mobile. The background music was converted from MP3 to Ogg.

If you use any of these assets in your own programs, please be sure to read and adhere to the licence terms.

This tutorial

In this tutorial we will create a 2D side scrolling platformer.

We will setup a background tile map, and implement basic platform movement - running, jumping and falling. We will detect player collisions with floors, walls and ceilings and restrict the player's movement appropriately. And we will add enemies to avoid, and objects for the player to collect.

The platformer will be controlled by keyboard on Windows, and on-screen touch controls on mobile.

Tutorial files

Click here to download the platform tutorial files.

Unzip them to a folder somewhere.

The tutorial is broken into 14 stages. Source code for each of the stages is included in the tutorial1.bglm - tutorial14.bglm files.

Run tutorial14.bglm to see what the final version will look like. The game has one smallish level, and the goal is to simply find the key, then find the lock, while avoiding touching the slime monsters that roam the level. Use the arrow keys to move, and the space bar to jump.

The bglm files are there for your reference (and so you can see how each stage is intended to look). However you are strongly encouraged to implement the game yourself and follow along with these tutorials. If something isn't working correctly, you can always check your code against the corresponding tutorial file.

The other files are the graphics and music, as well as the Basic4GL Mobile standard include files which are used for the on screen touch input (when running on mobile), and the Basic4GL Mobile standard graphics files which are used by the standard include files.

Let's go

Click here to start the tutorial.