Introducing Lime - A module to import 2D tilemaps in your game.

are you going to plan for isometric to start with and add it later. or will you just build coconut for orthagonal for now and then portion it out later with a modified API?

just thought if you can work out the common functions up front someone could take on that other job as a plugin. (not volunteering currently sorry!)

also can you actually do this in lua? i’m guessing you can

main.lua[lua]visual = coconut.create(map, “orthagonal”)[/lua]

coconut.lua[lua]function create(map, type)
local mapper = require(“lime.mapper.”…type)[/lua]

[import]uid: 6645 topic_id: 3598 reply_id: 11499[/import]

I think I will do something like that for version 0.2 however for “orthagonal” and “isometric” types you wouldn’t need to specify them when you create the map as they are all stored in the .tmx file as “orientation” however we may want to include more game-specific types for use in the Banana library for instance for creating the right type of physics such as “platformer”, “shooter” etc but not sure yet.

I will hopefully have a slightly modified version of Coconut up (0.2) later tonight when I get back from work that will just start preparing the way for a simple plugin system. [import]uid: 5833 topic_id: 3598 reply_id: 11503[/import]

hi graham.

note in my example i used
[lua]visual = coconut.create[/lua]
not
[lua]visual = lime.create[/lua]

presuming that the visual rendering would be done by coconut not lime, hence why you’d want a different extension of coconut for the isometric rendering :slight_smile:

i think we’re both on the same track I’m just explaining it badly. my main point being that coconut would expose eg :setWorldPos(object,x,y) but that’s actually an entirely different version of the function depending on whether the user has required “coconut.mapper.orthagonal” or “coconut.mapper.isometric”

j. [import]uid: 6645 topic_id: 3598 reply_id: 11506[/import]

I fully get what you mean, I’m currently doing a bit of rejigging so that when I upload the next version (which will be of Bounty + Lime + Coconut) there will be some blank plugins for the other stuff that I or someone else can fill in later. [import]uid: 5833 topic_id: 3598 reply_id: 11575[/import]

Just a quick update to say that I now have Isometric maps working. Will need testing etc and I’m not currently sure if the object layers will work correctly as far as positioning goes so I will test that now and I hope to have all this uploaded tomorrow.

I also have split off the Loading code from Lime and the Creation code from Coconut into separate files, there is now a creator file for both Isometric and Orthogonal maps as well as Loader files for CSV formatted maps (all working and those .tmx files are quite a bit smaller). XML loading is just in the Lime.lua file rather than a separate file at present. There are also dummy files for the three Base64 encoded map types (uncompressed, GZip compressed and ZLib compressed if anyone knows anything about that?).

[import]uid: 5833 topic_id: 3598 reply_id: 11658[/import]

supposedly some pure Lua implementations of some archive methods here.
http://lua-users.org/wiki/CompressionAndArchiving

(ie they don’t call external C libs)

but I’m not sure the formats you require are there

[import]uid: 6645 topic_id: 3598 reply_id: 11660[/import]

Looks like the ZLib one would require the C lib so that might be out for now, they’re not that important right now but would be nice in the future for people really trying to save space. For example the small map that I have used as an example is around 30kb in XML format yet in CSV it goes down to around 8kb (around the same for uncompressed Base64) but then with GZip it’s down to 1.6kb and with ZLib it’s down slightly more to 1.5kb. This compression would probably help dramatically if there are lots of large levels (naturally they don’t include the images etc for the tilesets, they are just text files).

Also, just done a quick test and it looks like the positions for objects set in Tiled Object Layers for Isometric maps are wrong (which is expected) so will look into that in a bit.

I think I will try to upload the stuff pretty soon rather than waiting till tomorrow. [import]uid: 5833 topic_id: 3598 reply_id: 11661[/import]

supposedly this is pure lua for both those formats
http://lua-users.org/wiki/ModuleCompressDeflateLua [import]uid: 6645 topic_id: 3598 reply_id: 11662[/import]

That’s awesome! It would be great to have those working. [import]uid: 5833 topic_id: 3598 reply_id: 11663[/import]

The first version of Bounty is up - http://grahamranson.co.uk/project-bounty.php - This download also contains the latest versions of Lime and Coconut that use the new “plugin” system. [import]uid: 5833 topic_id: 3598 reply_id: 11672[/import]

Thanks for these, they were very helpful (both for fixing problems and for seeing that it works with other maps), here are my findings for the ones that didn’t work:

  1. This one looks to have been made in the Java version of Tiled however I can’t see any differences between it and a Qt map. Will keep looking into this one.

  2. Now works, was a problem with working out when it should use the next tileset (a simple ‘+1’ in the check fixed that.

  3. Is an issue with Spacing and Margins, will look into getting those working.

  4. Same as above.

Anyone know if the current SpriteSheet code can use spacing?

New upload will be done soon. [import]uid: 5833 topic_id: 3598 reply_id: 11692[/import]

from what I can tell a spritesheet with spacing would need a sprite data file to say where each sprite was. although there’s a bug in the spritesheet code which is only taking the dimensions of the 2nd frame this should be ok if they’re all the same size.

it would be good though if ansca could add a padding parameter to the standard “fixed size” parser (ie no data file needed)

[import]uid: 6645 topic_id: 3598 reply_id: 11695[/import]

Yea I think that being able to pass in a spacing/padding value would be really good.

Probably a pretty quick thing for Ansca add in too. [import]uid: 5833 topic_id: 3598 reply_id: 11712[/import]

just looking for a few examples to test it…

i’ll update this post rather than adding more posts

  1. http://silveiraneto.net/2009/12/19/tiled-tmx-map-loader-for-pygame/ (errors)
  2. https://github.com/erisdiscord/gosu-tmx/tree/master/data/ (needs zip functions, unpacked version works)
  3. http://nerdculture.org/2009/07/14/tiled-maps-for-xna-full-support-for-the-tiled-map-xml-specification/ (needs zip, unpacked version works)
  4. http://geekanddad.wordpress.com/2010/06/22/enemies-and-combat-how-to-make-a-tile-based-game-with-cocos2d-part-3/ (needs zip, unpacked version works but it’s not showing the right tiles… (the meta tiles layer))
  5. http://paulsonapps.wordpress.com/2010/03/12/tutorial-1-tilemap-with-collision-game-cocos2d/ (works but his graphics are corrupt within Tiled itself)
  6. http://www.71squared.com/2009/05/iphone-game-programming-tutorial-6-tiled-map-class/ (works)
  7. http://blog.nickgravelyn.com/2010/03/know-when-to-be-lazy/ (unpacked version gives sprite sequence frame error)
  8. http://tiledlib.codeplex.com/releases/view/51189 (same issue as #7)
  9. http://flixel.org/forums/index.php?topic=264.0 (works)

hope these help

[import]uid: 6645 topic_id: 3598 reply_id: 11674[/import]

might be worth thinking how this would be implemented
http://www.swfcabin.com/open/1280898662

for that first level… the spritesheet is consistent across screens. so even if they are separate maps they use the same spritesheet. (although corona caches bitmaps i think so that might not matter)

if it was just done as one big map split up into several screens the whole map doesn’t want to be rendered at once. just the individual scrolling area.

maybe it’s better to do each as a separate tmx file but potentially you’d want to ensure there’s no real loading/rendering time between flip screens. presumably it’s ok?

j
[import]uid: 6645 topic_id: 3598 reply_id: 11719[/import]

wow, I’m away for a few days and stuff happens. :wink:

Graham are you using github or anything to host your code? Then we could keep up with your changes and maybe offer back some patches?

[import]uid: 9562 topic_id: 3598 reply_id: 11787[/import]

@jmp

I replied to your comment yesterday, I have no idea where it went though. Essentially I said that it could probably be implemented with the Object Layer in Tiled (as you can give Objects a size essentially making them a Zone). However we would have to think about how we would want to implement that in Mango or whatever as I don’t want things going to specific etc. Could make it so for example there could be a mango.showZone(5) function or something similar and then it would be up to the user and their game to decide when to change zones I guess.

@jtal

Currently the only source control I’m using is actually Dropbox :slight_smile:

I’ve never used Git before only SVN, anyone have any preference either way? I’ll either go with GitHub or Google Code.

I’m also used to using TortoiseSVN, is there a Mac equivalent (for SVN or Git)? [import]uid: 5833 topic_id: 3598 reply_id: 11831[/import]

do you have any idea of rendering time vs number of tiles (ie X * Y * Z) on a device? I was thinking that actually sub-levels as small as that example would be fine with different .tmx files anyway [import]uid: 6645 topic_id: 3598 reply_id: 11859[/import]

I haven’t done any performance tests yet and although I would also agree that loading up small maps such as the ones in that example from separate .tmx files would no doubt be fast, wouldn’t making so many small maps (and keeping them all organised) be fairly frustrating for the developer? [import]uid: 5833 topic_id: 3598 reply_id: 11867[/import]

Graham, I’ve used cvs, svn, and git for years now. svn is ok, I prefer git since it makes it easier for multiple developers to work on the same project. I recommend github- its free for public / open source projects.

On my mac I just did:

sudo port install git

Then, after you create the github project it tells you how to init your repo. Using git is similar to svn (until you get to using branches).

git commit commits your changes to your local repo. git push origin master will push the changes up to github making them available to all of us. We will do git pull from time to time to immediately get any changes you pushed.

I’m ok with svn too though if youre more comfortable with that. There are some free svn hosting providers out there.
[import]uid: 9562 topic_id: 3598 reply_id: 11935[/import]