Page 1 of 2

Tiled Drawer

Posted: Wed May 18, 2011 3:16 pm
by adrix89
Based on work from Ninwa http://love2d.org/forums/viewtopic.php?f=5&t=2097
I present you the super modified version
Features:
My very own inefficient .tmx parser
Camera
Buckets(Damn you feature I hate you!)
Spritebatches
Support for multiple tilesets
Arbitrary layer drawing(so you can you can draw over your sprites)
Your very own 512x512 map so you can claw your eyes when yous see the framerate(press m to change to map 2)
And lots of obsolete files and comments as well as test functions so you can see how messy I code

The engine is still WIP and is generally intended for those who like to tinker with things
Also since its intended for a game don't expect it to be any less quirky then it is
http://dl.dropbox.com/u/1027218/gamesource.love

Warning: Do not export from Tiled maps with other encoding other then CVS,that includes the default xml encoding which is shit

Update: Added y collision offset as well as change the image directory so you can load .tmx files in tiled
Updated!: Retarded performance edition
Update: Fixed image initializing, added some smart garbage collection, cron.lua FTW!

Re: Tiled Drawer

Posted: Wed May 18, 2011 4:57 pm
by Franc[e]sco
erm, could you Include the profiler module or add a link to it?

Re: Tiled Drawer

Posted: Wed May 18, 2011 5:15 pm
by adrix89
Damn that shouldn't be there,just delete the require

Fixed it

Re: Tiled Drawer

Posted: Wed May 18, 2011 10:19 pm
by Franc[e]sco
The chests drawing order is a bit messed up but it's pretty nice :)

Re: Tiled Drawer

Posted: Wed May 18, 2011 11:20 pm
by tentus
Maybe it's because the render was larger than my screen, but collision detection seemed way off, and a little nonsensical. Also, I could see tiles at the top of the screen get clipped at some points.

Re: Tiled Drawer

Posted: Thu May 19, 2011 6:54 am
by adrix89
tentus wrote:Maybe it's because the render was larger than my screen, but collision detection seemed way off, and a little nonsensical. Also, I could see tiles at the top of the screen get clipped at some points.
The top of the screen is because the rate is 80 while the sprites are 170,it wouldn't happen if the rate was the same, you can fix it by adding -2 to the selector for loop y variable
I wanted people to know about it since its a limitation of the engine
As for collision it should be screen independent,can you post your screen dimensions?
The collisions on y should aligned perfectly the front edge of the chest with the white dot
As for x you can see it between the two chests
As for the quirkiness it should be because of the collision map not the engine,since again the rate is 80 not the whole sprites
If it really is nonsensical can you post a screen with the problem collisions?
Franc[e]sco wrote:The chests drawing order is a bit messed up but it's pretty nice :)
There is no drawing order,it renders layer 1 then sprites then layer 2
The good thing with this is that you can script it when to draw and when not to draw

Re: Tiled Drawer

Posted: Thu May 19, 2011 11:47 am
by Lafolie
Yeah... I could walk under the chests and bridges. Plus I could walk over the water tiles, and could not walk along the path that leads from the starting area to outside - I had to walk to the bridge and go all the way around.

Re: Tiled Drawer

Posted: Thu May 19, 2011 12:48 pm
by adrix89
Lafolie wrote:Yeah... I could walk under the chests and bridges. Plus I could walk over the water tiles, and could not walk along the path that leads from the starting area to outside - I had to walk to the bridge and go all the way around.
Check the tiled map collision layer and tell me if its accurate with the collisions in game

Re: Tiled Drawer

Posted: Thu May 19, 2011 9:40 pm
by Lafolie
Will do when I get the chance.

Re: Tiled Drawer

Posted: Fri May 20, 2011 1:35 pm
by adrix89
Updated it for massive performance increase!
Basically I just check if we a are in a new bucket and if we are not use the previous calculated spritebatches
There is also allot less memory consumption and pretty much disregards the layer penalty
Also updated the maps, now the first map is a layer test with 7 layers, while the second is a mind boggling 512x512 map
Remember to press lshift to traverse faster ;)