Page 1 of 1

Tips and solutions for creating stages

Posted: Sat Feb 01, 2014 10:14 am
by carbajosa
Hello, love community!

I just wanted to ask if there is a certain way to create stages / rooms properly.
What I'm currently have in mind is to create a table of invisible bounding boxes like this:

Code: Select all

{1, 1, 1},
{1, 0, 1},          where 1 = Solid, 0 = Free Space
{1, 1, 1}
Then loading a graphics on top of that like

Code: Select all

love.graphics.draw(ImageOfRoom, x, y)
I am not trying to achieve a big room though, just a big world divided into small parts. I am currently creating a 2D Sidescroller RPG like the old Valkyrie Profile games. It has small but many rooms to explore. Also, I don't like using tilesets because I feel like I'm limited to square tiles, or am I incorrect? Anyway, to create a stage, I am planning to render it first in 3D and capture a 2D image from it. Same goes for creating spritesheets. 3D model then capture the 2D poses. etc.

Will it have an impact from the speed of the game? or is there a particular technique that can be used other than this?

EDIT:
Also, is there a way to insert the stage design from a text document?
For example, I have stg.txt:

Code: Select all

1,1,1,1
1,0,0,1
1,1,1,1
then in main.lua

Code: Select all

self.stageDesign = {}
for line in love.filesystem.lines("stg.txt") do
table.insert(self.stageDesign, line)
end
then when I try printing using print(self.stageDesign[1][1]) it gives me an error.
It appears that it is storing them as a string which becomes

Code: Select all

Index 1 = "1,1,1,1"
Index 2 = "1,0,0,1"
Index 3 = "1,1,1,1"

AND NOT

Index 1 = 1
Index 2 = 1
..
Index 2,2 = 0
..
and so on ..
Any ideas how?

Re: Tips and solutions for creating stages

Posted: Sat Feb 01, 2014 10:42 am
by Azhukar
You can directly load lua files and use those as data storage.

main.lua

Code: Select all

local level1 = love.filesystem.load("level1.lua")()
print(level1[2][1]) --prints 2
level1.lua:

Code: Select all

local leveldata = {
	{1,1,1,1},
	{2,0,0,1},
	{1,1,1,1},
}

return leveldata

Re: Tips and solutions for creating stages

Posted: Sat Feb 01, 2014 11:46 am
by carbajosa
Azhukar wrote:You can directly load lua files and use those as data storage.

main.lua

Code: Select all

local level1 = love.filesystem.load("level1.lua")()
print(level1[2][1]) --prints 2
level1.lua:

Code: Select all

local leveldata = {
	{1,1,1,1},
	{2,0,0,1},
	{1,1,1,1},
}

return leveldata

Amazing! I didn't know that can be done. Thank you very much, sir! :)

Re: Tips and solutions for creating stages

Posted: Sat Feb 01, 2014 12:35 pm
by kikito
I wrote a tutorial exactly about this very topic:

https://github.com/kikito/love-tile-tutorial

Just replace "drawq" with "draw".

Re: Tips and solutions for creating stages

Posted: Sun Feb 02, 2014 1:27 am
by carbajosa
kikito wrote:I wrote a tutorial exactly about this very topic:

https://github.com/kikito/love-tile-tutorial

Just replace "drawq" with "draw".
Ahh, thank you very much! That would be really helpful.
Well I'm now considering using tiles... hmm