Tips and solutions for creating stages

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
carbajosa
Prole
Posts: 15
Joined: Fri Jul 12, 2013 5:17 am

Tips and solutions for creating stages

Post 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?
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Tips and solutions for creating stages

Post 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
carbajosa
Prole
Posts: 15
Joined: Fri Jul 12, 2013 5:17 am

Re: Tips and solutions for creating stages

Post 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! :)
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Tips and solutions for creating stages

Post by kikito »

I wrote a tutorial exactly about this very topic:

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

Just replace "drawq" with "draw".
When I write def I mean function.
carbajosa
Prole
Posts: 15
Joined: Fri Jul 12, 2013 5:17 am

Re: Tips and solutions for creating stages

Post 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
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests