Skip to content

Platformer Tutorial

Mighty Pancake edited this page Apr 9, 2020 · 7 revisions

Goal

The goal of this tutorial is to create a simple platformer game, where the player has to jump between platforms. It’s not a complicated game, but once you get how the library works you can develop it however you want.

Before you start

Make sure you’re familiar with Getting Started article, so you know the basics.

Also, keep in mind this tutorial is just kept as simple as possible, so it misses various information on different topics. However, whenever something is mentioned here you can always (and it’s very advised to) click the link discussing the topic/function. With that being said, let’s jump right into action!

Quick set up

To start, download this empty game template for pancake library here.

After this, you have to search for the main.lua file (it should be in the main folder). Once you’ve found it, double click it and edit it in an editor of your choice.

Now search for this piece of code:

function love.load()

pancake.init({window = {pixelSize = love.graphics.getHeight()/64}})

end

This is the line that initiates the library. Long story short, it sets things up so they can work and loads animation.

Creating the player object

To create our player object simply use pancake.addObject() like this under the pancake.init({window = {pixelSize = love.graphics.getHeight()/64}}) line of code:

player = pancake.addObject({x = 0, y = 20, width = 6, height = 11, name = "dexter", colliding = true, offsetX = -5, offsetY = -2})

This will create a variable named player and assign an object to it that has different attributes. Now, we want to run our game to see the results of our work.

Running the game

It’s really simple. Press and hold the left mouse button on the folder that you store the game files in and drag it to "LÖVE.exe". If you don’t have LÖVE yet, please head back to Getting Started.

When you do this you should see that the pancake animation plays and nothing else really happens…​ Why is that? That’s because our player object exists somewhere but it’s actually invisible right now! Let’s make him more alive, shall we?

Invisible, yet alive

How do you make an object visible? Well, you give it an image or an animation. In this case, we will create an animation, so he doesn’t look like he’s dead. To make that, we need some images (frames), so that we can define our animation!

Clone this wiki locally