Have you ever been sick of writing - 1, 4, 1, 0, 0, 0, 0, 6, - to draw your levels. Because i am!
There has to be a simpler way.
How about using an image's colours for different blocks. A block-A pixel.
Can you please tell me how this is done so i can add it to my game Platformer X.
How to draw levels with images!
Re: How to draw levels with images!
Another Kind of World does this.
Check out world.lua and the levels directory. Here's an excerpt from world.lua:
Check out world.lua and the levels directory. Here's an excerpt from world.lua:
Code: Select all
for x = 0, self.width-1 do
for y = 0, self.height-1 do
red, green, blue, alpha = self.baseImg:getPixel(x, y)
if red == 255 and green == 0 and blue == 0 then
love.graphics.draw(self.gfxNormal, x*8*self.scale, y*8*self.scale, 0, 3, 3)
elseif red == 0 and green == 255 and blue == 0 then
love.graphics.draw(self.gfxTop, x*8*self.scale, y*8*self.scale, 0, 3, 3)
elseif red == 255 and green == 255 and blue == 0 then
love.graphics.draw(self.gfxUnder, x*8*self.scale, y*8*self.scale, 0, 3, 3)
elseif red == 0 and green == 255 and blue == 255 then
...
Re: How to draw levels with images!
There are tons of ways to solve this. I tend to create level editors in my games to get total control. Typically, I let the editor write automated lua code to files containing the data for each level.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Re: How to draw levels with images!
well, i am currently using a system where i have a level .txt file that looks something like this:
111
101
111
(^that would be a box)
and it gets read into an array, where i use it in my game and in love.draw()
(love.draw renders the level)
if you want some code i can post some.
is this what you want?
111
101
111
(^that would be a box)
and it gets read into an array, where i use it in my game and in love.draw()
(love.draw renders the level)
if you want some code i can post some.
is this what you want?
Re: How to draw levels with images!
i like how "another kind of world" did it, so im working on my own version, ill create a new thread when its gotten anywhere.
saved by a scholarship..
redesigned my "avatar"
redesigned my "avatar"
Re: How to draw levels with images!
this is what i made, let me know if it helps! although its pretty rough
Drawing Maps With Images
Drawing Maps With Images
saved by a scholarship..
redesigned my "avatar"
redesigned my "avatar"
-
- Prole
- Posts: 36
- Joined: Wed Jul 25, 2012 10:51 pm
- Location: Right behind you. I know you looked. Heck, even I looked
Re: How to draw levels with images!
Stabyourself.net's OrthoRobot does this fantastically. Not sure how... its open source though, just like Mari0
Who is online
Users browsing this forum: No registered users and 3 guests