*WIP* [Tutorial] Making a platformer for beginners!

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
AtomCastDev
Prole
Posts: 37
Joined: Fri Aug 02, 2013 1:44 pm

*WIP* [Tutorial] Making a platformer for beginners!

Post by AtomCastDev »

ALERT! please reply if you liked it and if I should continue it?

Löve Platformer Game Programming Tut - 01

This is a series of tutorials that I'm writing as I learn game programming in Löve2D.I will put lots of work into the game itself
and I will make sure you will understand every single detail of the
program.
Please remember this isnt for complete beginners but for those who
know some knowledge in programming like:

What is a variable? And how is it different than a command statement?
What is an array? A table? An integer? A boolean?
How to draw in Löve?what is 1 + 1?

To follow along you will need to download the Löve engine and install
it,and have a decent text editor.I would reccomend sublime text 2
unlicensed because it is very easy and comfortable to use, or you can
use notepad++.

For this tutorial I will also translate everything into a non
complicated language called english ;D

-THE SKELETON OF A Löve CODE-

The basic skeleton of a love code for me is the first 3 lua files
you will create.
the first is a text file called "main.lua" (remove the quotation marks)
this lua text file is basically the vertebrae in your game, it consists of 3
(note: later on there will be more functions!)
functions which are:

Code: Select all

function love.load()


end
function love.update(dt) 

end
function love.draw()


end
You can only type code in the space between the function and end.

As you noticed the 2nd function has a dt in the parenthesis
this stands for delta time which we are gonna use later on.

For now these functions will be empty unless you want to add in
the code:

love.graphics.setBackgroundColor(0,0,0)

into function love.load()

which sets the games background color.The 3 numbers are in order
"red,green,blue" right now the bg color is black.

right now your code should look like this
(I added in comments to tell you what each function will handle.To add comments type in -- then your comment i.e --this is awesome!)

Code: Select all

function love.load()

--love.load loads/sets all the variables and images

love.graphics.setBackgroundColor(255,255,255)

end
function love.update(dt)

--love.update does all the math work

end
function love.draw()

--love.draw draws stuff...

end
now that you are finished with the game's vertebrae and 1/3 of the game's skeleton we will move on to the life frame of the game,AKA the config file.
The config file is what gives our game the basics to be a game.

To make our config file,you gotta go to file>new which creates a new text file,save the file and name it "conf.lua". (remove the quotation)
In this lua text file there will be only one function through out the series,
this function will be called:

Code: Select all

function love.conf(t)


end
in this function there will be

4 lines of code which are

Code: Select all

t.title = "Adventure tutorial game" --sets the name of the game (dont remove quotations)
 
 t.author = "Jacobe the test name" --sets the name of author (dont remove quotations)
 
 t.screen.width = 800 --sets screen width

 t.screen.height = 600 --sets screen height
now a reminder to let you know that you
have to mess around with screen.height/width because everyone has a different screen measure so
just mess around with it in your game.

your code should now look like this:

Code: Select all

function love.conf(t)
 t.title = "Adventure tutorial game" --sets the name of the game (dont remove quotations)
 
 t.author = "Jacobe the test name" --sets the name of author (dont remove quotations)
 
 t.screen.width = 800 --sets screen width

 t.screen.height = 600 --sets screen height
    
end
now that you are finished with the game's life frame and 2/3 of the game's skeleton we will move
on to the head of the game,AKA the player file!
with this the final piece of the skeleton we can finally call it a game!

To make our player file,you gotta go to file>new which creates a new text file.Inside of your
game folder containing main and conf.lua,make a new folder called "includes" (remove quotations)
save the file and put it inside of the includes folder and name it "player.lua". (remove the
quotations)

In this lua text file there will be a BAZILLION functions through out the series, and to start
off player.lua,go into main.lua and at the very top of the whole source code, and yes ontop of
love.load() type in require "includes/player" if you put in includes/player.lua it will create
problems.
your code in main.lua should now look like this

Code: Select all

require "includes/player"

function love.load()

--love.load loads/sets all the variables and images

love.graphics.setBackgroundColor(255,255,255)

end
function love.update(dt)

--love.update does all the math work

end
function love.draw()

--love.draw draws stuff...

end
this basically includes player.lua into the code's awesome family and now we begin to tinker with player.lua

to start off with
player.lua you will need to create the player variables
inside of player.lua
which are:

Code: Select all

player = {}
player.x = 5
player.y = 5
player.xvel = 0
player.yvel = 0
player.friction = 10
player.speed = 1500
These variables are not in a function.
With these variables set, you can now move on
into drawing the player.

The first step to drawing a player is making a new folder inside
of your game folder which holds main.lua and conf.lua,make a new
folder called "resources" (remove quotations), with this put in
your player's picture, the player needs 2 different
pictures that shows the player facing left and right.

rename your 2 images with playerL and playerR
with the player facing left being playerL and the player
facing right being playerR.

now you can finally draw your player by making a new variable
called:

Code: Select all

player.pic = love.graphics.newImage("resources/playerR.png")
your code in player.lua should now look like this:

Code: Select all

player = {}
player.x = 5
player.y = 5
player.xvel = 0
player.yvel = 0
player.friction = 10
player.speed = 1500
player.pic = love.graphics.newImage("resources/playerR.png")
Last edited by AtomCastDev on Thu Aug 08, 2013 10:42 pm, edited 2 times in total.
Sharing the one world

Also check out my friend's game!
http://love2d.org/forums/viewtopic.php?f=5&t=43276
User avatar
BulbaMander
Citizen
Posts: 65
Joined: Sat Dec 15, 2012 7:00 pm

Re: [Tutorial] Making a platformer for beginners!

Post by BulbaMander »

Better intro to the skeleton than I could ever find. Someone should link this in the wiki.
It takes an idiot to do cool things. Thats why they're cool. :emo:
AtomCastDev
Prole
Posts: 37
Joined: Fri Aug 02, 2013 1:44 pm

Re: [Tutorial] Making a platformer for beginners!

Post by AtomCastDev »

BulbaMander wrote:Better intro to the skeleton than I could ever find. Someone should link this in the wiki.
I'm glad you like it :D you should also check out my game that I did with monkey dev called "Slime Chunk Revolution"
Sharing the one world

Also check out my friend's game!
http://love2d.org/forums/viewtopic.php?f=5&t=43276
User avatar
NightKawata
Party member
Posts: 294
Joined: Tue Jan 01, 2013 9:18 pm
Location: Cyberspace, Room 6502
Contact:

Re: [Tutorial] Making a platformer for beginners!

Post by NightKawata »

If this is done right it may be the first not crappy platformer tutorial the forums has gotten :(
"I view Python for game usage about the same as going fishing with a stick of dynamite. It will do the job but it's big, noisy, you'll probably get soaking wet and you've still got to get the damn fish out of the water." -taylor
AtomCastDev
Prole
Posts: 37
Joined: Fri Aug 02, 2013 1:44 pm

Re: [Tutorial] Making a platformer for beginners!

Post by AtomCastDev »

NightKawata wrote:If this is done right it may be the first not crappy platformer tutorial the forums has gotten :(
that's weird,I havent seen any tutorials on a full platformer game in these forums at all.
Sharing the one world

Also check out my friend's game!
http://love2d.org/forums/viewtopic.php?f=5&t=43276
User avatar
IAsep-TrixI
Citizen
Posts: 89
Joined: Mon Aug 12, 2013 4:22 am
Location: Philippines,Asia

Re: *WIP* [Tutorial] Making a platformer for beginners!

Post by IAsep-TrixI »

This is a great tutorial, I got the basic skeleton/frame of my game because of this, the game is in the link down below :P
An agent of the free

check out the game I'm doing with Jkash!
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 24 guests