-
Notifications
You must be signed in to change notification settings - Fork 2
Platformer Tutorial
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.
Make sure you're familiar with https://github.com/pancake-library/pancake-wiki/wiki/Getting-Started[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!
To start, download this empty game template for pancake library https://github.com/pancake-library/empty-template[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 https://github.com/pancake-library/pancake-wiki/wiki/pancake.init()#pancakeinitsettings[initiates the library]. Long story short, it sets things up so they can work and loads animation.
To create our player object simply use https://github.com/pancake-library/pancake-wiki/wiki/pancake.addObject()[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 https://github.com/pancake-library/pancake-wiki/wiki/Objects#objects-attributes[attributes]. Now, we want to run our game to see the results of our work.
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 https://github.com/pancake-library/pancake-wiki/wiki/Getting-Started[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?
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!
Wiki created by MightyPancake
Main articles:
Tutorials:
Topics:
Functions: