Help needed for platformer
Posted: Sun Jan 10, 2016 1:19 am
I have this platformer game that I need help with.
And how to make the terrain not cycle through one block.
how do I make more than one block?
Here is main.lua:
conf.lua
Test the code out. Show me some code and how it works.
Thanks for helping! See the comments I made they may help you!
And how to make the terrain not cycle through one block.
how do I make more than one block?
Here is main.lua:
Code: Select all
-- Made By: CraftedPixel CC - BY 4.0 See here: http://creativecommons.org/licenses/by/4.0/ --
function love.load(dt)
blocksize = 25 -- You can modify this without breaking the game
godown = go -- tells script to go to next line
b = {'block', 255, 150, 0} -- this is a block. I am giving them RGB values and block nicknames
s = {'sky', 0, 150, 255} -- {block name, Red, Green, Blue}
g = {'ground', 100, 255, 100}
terrain = { -- This should look like a smiley face when code is run
b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,godown,
s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,godown,
s,s,b,b,s,s,s,s,s,s,s,s,b,b,s,s,godown,
s,s,b,g,s,s,s,s,s,s,s,s,g,b,s,s,godown,
s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,godown,
s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,godown,
s,b,b,b,s,s,s,s,s,s,s,s,b,b,b,s,godown,
s,s,b,b,b,s,s,s,s,s,s,b,b,b,s,s,godown,
s,s,s,b,b,b,b,b,b,b,b,b,b,s,s,s,godown,
s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,godown,
s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,godown,
g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,godown,
stopdraw} -- You can make your own level if you want :D
px = 10 -- I was planning to make a character but the terrain is my greatest priority
py = 10
drawx = 0 -- some draw numbers for the positon of the blocks
drawy = 0
drawnumber = 0 -- Terrain scanning number
end
function love.update(dt)
drawx = drawx + 1
drawnumber = drawnumber + 1
if terrain[drawnumber] == go then -- Cycles through the level given
drawx = 0
drawy = drawy + 1
drawnumber = drawnumber + 1
end
if terrain[drawnumber] == stopdraw then -- this resets the drawing when stop signal is reached
drawx = 0
drawy = 0
drawnumber =1
end
end
function love.draw(dt)
love.graphics.setColor(255,255,255)
love.graphics.print(terrain[drawnumber], 10, 10)
love.graphics.print(drawnumber, 10, 25)
love.graphics.setColor(terrain[drawnumber][2],terrain[drawnumber][3],terrain[drawnumber][4]) -- Gets color of current terrain block
love.graphics.rectangle("fill",drawx * blocksize, drawy * blocksize, blocksize, blocksize) -- Draws a block on terrain block
end
Code: Select all
function love.conf(t)
t.window.height = 600
t.window.width = 800
t.title = "Map testing!"
end
Thanks for helping! See the comments I made they may help you!