Page 135 of 181

Re: What's everyone working on? (tigsource inspired)

Posted: Wed May 18, 2016 4:10 pm
by Sulunia
About losing Z index, that depends on how you're coding. Usually, you just draw everything in a specific order and voilá

Re: What's everyone working on? (tigsource inspired)

Posted: Wed May 18, 2016 8:53 pm
by Jasoco
The way I deal with Z indexing on images is to throw every single drawable into a table and sort that then draw the objects. Table sorting in Lua is pretty damn fast. I created my own DrawPool library for it too.

I use it in every project I make. It's much easier to deal with drawing when you don't have to worry about what order items have been drawn. Let the DrawPool sort it by their "layer", or "distance from camera" and you're set. Just draw whenever.

Re: What's everyone working on? (tigsource inspired)

Posted: Wed May 18, 2016 10:13 pm
by Sulunia
Jasoco wrote:The way I deal with Z indexing on images is to throw every single drawable into a table and sort that then draw the objects. Table sorting in Lua is pretty damn fast. I created my own DrawPool library for it too.

I use it in every project I make. It's much easier to deal with drawing when you don't have to worry about what order items have been drawn. Let the DrawPool sort it by their "layer", or "distance from camera" and you're set. Just draw whenever.
I for instance like drawing everything by hand in a specific order. Sure, some cases is good to have a DrawPool like you do, but in others i just prefer to have the values exposed so i can fine adjust where everything should go.
Code usually gets messier though, so it has that drawback. :monocle:

Re: What's everyone working on? (tigsource inspired)

Posted: Wed May 18, 2016 11:04 pm
by Jasoco
Sulunia wrote:I for instance like drawing everything by hand in a specific order. Sure, some cases is good to have a DrawPool like you do, but in others i just prefer to have the values exposed so i can fine adjust where everything should go.
Code usually gets messier though, so it has that drawback. :monocle:
But my method lets you fine tune placement better than just calling love.graphics.* functions straight. For instance, it lets you choose what layer to place the drawable. So even if I call a circle first and a square second, if the circle has a higher layer, it's going to draw last and on top. This is useful because you can't always be certain what order entities will be updated and drawn in since for is unpredictable with pairs() and you can't sort unnumbered indexed tables. Only ones with ordered pairs. My DrawPool makes sure I don't have to care. Plus it adds barely any extra time since table.sort is really fast. Plus it helps with any kind of game with any sort of 3D or pseudo 3D style to it like TMNT style brawlers and the like. I initially invented the method when I was toying around with a Star Fox style SuperFX engine.

Basically I can create drawables like so:

Code: Select all

drawPool:push { kind = "rect", x = 100, y = 100, w = 100, h = 100, color = {255,0,0}, layer = 100 }
drawPool:push { kind = "circle", x = 200, y = 120, rad = 80, color = {0,0,255}, layer = 95 }
drawPool:push { kind = "text", x = 50, y = 200, width = 300, align = "center", shadow = true, font = your_font, color = {255,255,255}, layer = 103 }
drawPool:push { kind = "image", x = 80, y = 60, image = fluffyBunny, quad = bunnyQuad[1], rot = 0, sx = 1, sy = 1, iox = 0, ioy = 0, layer = -304.43 }
...
And they'll draw in the right order. I could modify it to make the push() function work exactly like the equivalent drawable, but I use a table like this so I can add extra features if needed and it's easier to tell which argument does what and lets you skip arguments if you want.

But of course people can do what they want how they want. I made a library for myself so it could be reused and because someone was interested in my method so I drew up a Readme documentation (Which is larger in character size than the code itself) and let him have it. I'd put it on GitHub but I'd rather someone more knowledgeable look over the code and make sure it looks proper enough before I do that. Plus I'd want to make it more user-friendly. But this works really well.

Re: What's everyone working on? (tigsource inspired)

Posted: Thu May 19, 2016 6:32 am
by D0NM
well, thank u.
but i do sort my objects from the very beginning. ^__^
and... thanks to Jasoco, i've got a new idea to implement (not related to the last posts, but related to the "steps dust clouds particles" )

Re: What's everyone working on? (tigsource inspired)

Posted: Thu May 19, 2016 6:53 am
by Jasoco


As usual, I don't even know where this is going. I just started with a prototype and it somehow turned into this. And it currently doesn't even do what the original prototypes did. But it does more.

I want to make it a twin stick shooter. I'm really inspired by Enter the Gungeon lately. But I don't want to rip it off. Plus it's been done now.

Re: What's everyone working on? (tigsource inspired)

Posted: Thu May 19, 2016 10:16 am
by s-ol
Jasoco wrote:I'd put it on GitHub but I'd rather someone more knowledgeable look over the code and make sure it looks proper enough before I do that. Plus I'd want to make it more user-friendly. But this works really well.
Don't think I'm more knowledgeable than you but I'd def look into it.

Re: What's everyone working on? (tigsource inspired)

Posted: Thu May 19, 2016 1:22 pm
by Sulunia
s-ol wrote:
Jasoco wrote:I'd put it on GitHub but I'd rather someone more knowledgeable look over the code and make sure it looks proper enough before I do that. Plus I'd want to make it more user-friendly. But this works really well.
Don't think I'm more knowledgeable than you but I'd def look into it.
Agreed, i'm particularly interested aswell :D

Re: What's everyone working on? (tigsource inspired)

Posted: Thu May 19, 2016 1:45 pm
by marco.lizza
Jasoco wrote:I created my own DrawPool library for it too.
I opted for a similar approach, in some projects, but using a queue of closures with priority. That way I simply enqueue the drawing snippets without the need to define a specification format to be interpreted.

Re: What's everyone working on? (tigsource inspired)

Posted: Thu May 19, 2016 5:34 pm
by Davidobot
I'm working on a Pong clone: Image

Btw guys, I was the one Jasoco shared his DrawPool library with.