Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Tiled TMX Map Loader 2.0

Author
Message
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 5th May 2014 19:23
Anti-lock bump; I would like to add things to this thread in future.

Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 8th May 2014 09:46 Edited at: 8th May 2014 09:48
And again Clonkex, Thank You!

I think, its right to mention it, before it gets to late for that.

This TMX Loader saves me a lot of time for one of my next projects.
The code is very well written, like your GUI plguin. Iam feeling bad for not to contribute to the community as much as you do^^

I hope to see more updates on this project.

[/url]
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 8th May 2014 10:49
Quote: "And again Clonkex, Thank You!"


No, thank you! Sounds like you saw my signature and opened all the links

Quote: "This TMX Loader saves me a lot of time for one of my next projects."


It's awesome to hear people are using some of my stuff, but please remember that the original code for the TMX loader was written by Phaelax. I just took his XML loader code and his TMX loader code and fixed them up so they were more usable and did more stuff. Credit where credit's due

Quote: "The code is very well written, like your GUI plguin."


Thanks! I must warn you, though, there are some bugs that I haven't yet fixed.

Quote: "Iam feeling bad for not to contribute to the community as much as you do^^"


Haha I just write stuff that I need and then post it here so others can make use of it. The only real work I put forth for the community is organising the code nicely and writing information on how to use it.

Quote: "I hope to see more updates on this project."


Me too As soon as I get some free time (maybe tonight or tomorrow), I'll run some proper testing on this code and fix all the bugs with it. I still intend to actually finish Placement Editor Professional at some point; it's full of bugs and doesn't have half the features I wanted in it.

WoodenDragon
9
Years of Service
User Offline
Joined: 27th Jun 2014
Location: United States
Posted: 28th Jun 2014 00:07
Thank you so much for this wonderful toolkit Clonkex! I'm just getting back into AppGameKit and it's saved me a considerable amount of time already, plus it makes the map process so much cleaner for me.

I know your busy, so if your willing, there's no rush... I was wondering if it would be possible to have the property by tileset implemented? I've been trying to figure it out, but it's beyond my level at this point.

I'm currently looping through all the tiles on a specific layer and then use GetSpriteCollision to test for hits. I'm doing this because I'm not always on a specific tile, so collision works better than the x,y coordinates of the character, however I'm not that great of a coder, so I'm sure there are better ways to do what I'm trying to accomplish. Anyways, I want specific tiles on certain layers to have properties that will affect movement and other things. I would love to have this handled all within the tmx_engine.

As I have been working, I thought it would be great if we had access to the following functions: tmx_GetPropertyNameByTile, tmx_GetPropertyValueByTile, tmx_GetPropertyNameBySpriteID, tmx_GetPropertyValueBySpriteID, tmx_GetTileBySprite

Thanks again, regardless of whether your willing to look into any of this or not! Your work helps and teaches me greatly and is appreciate more than you know!
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 6th Jul 2014 16:44
Quote: "Thank you so much for this wonderful toolkit Clonkex! I'm just getting back into AppGameKit and it's saved me a considerable amount of time already, plus it makes the map process so much cleaner for me."


You are very much welcome!

Quote: "I know your busy, so if your willing, there's no rush... I was wondering if it would be possible to have the property by tileset implemented? I've been trying to figure it out, but it's beyond my level at this point."


If I get time tonight (as in, the next ten minutes), I'll take a look at it.

Quote: "As I have been working, I thought it would be great if we had access to the following functions: tmx_GetPropertyNameByTile, tmx_GetPropertyValueByTile, tmx_GetPropertyNameBySpriteID, tmx_GetPropertyValueBySpriteID, tmx_GetTileBySprite"


Interesting idea

Quote: "Thanks again, regardless of whether your willing to look into any of this or not!"


No problem I'm looking at the code right now, but I've left it so long I'm having to re-learn how it works Luckily I think my well-designed code will make it easy to finally add per-tile properties support and fix any bugs I can find

Quote: "Your work helps and teaches me greatly and is appreciate more than you know!"


Thanks!

Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 8th Jul 2014 18:29 Edited at: 8th Jul 2014 18:31
Update!

Finally, after many months, I've found the time to update this and correct many bugs. Additionally, I have added support for per-tile properties. *cheering and clapping*

New download in first post.

Changelog:


There are, however, still bugs.

Known issues:

- tmx_GetTileIndex and tmx_GetTileIndexBySpriteFast won't work with Iso or Stag maps; use tmx_GetTileIndexBySprite instead
- Depending on how AppGameKit works, there may be memory leaks when loading and deleting more than 1 map (loaded images are not deleted in tmx_DeleteMap)
- Finding tile indices is currently really hacked and could be a lot better. I want to rewrite how this works so all commands work with all map types
- There are quite a few missing commands, for example, there's no command to set visibility of object layers



Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 8th Jul 2014 18:37
Quote: "What I wanted was the sprite ID of the tile, but I got it worked out."


Good-oh. For the record, you should do something like this:



Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 2nd Aug 2014 05:19
Lost Dragon
13
Years of Service
User Offline
Joined: 22nd Aug 2010
Location:
Posted: 5th Aug 2014 23:45
Cool. I'll check it out.

I believe the last time I tried this I was loading in a 512x512 tile map and it took too long to load.

That spun me off into trying to do chunk loading. Then I thought about just making the maps smaller. Then I got distracted with other development software - then more distraction with other ideas...

I probably need to use this to make a map conversion routine in a binary format. I could use Tiled and then convert. That should load fast enough on a PC.
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 6th Aug 2014 03:29
Quote: "I probably need to use this to make a map conversion routine in a binary format. I could use Tiled and then convert. That should load fast enough on a PC."


Good idea

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Aug 2014 18:20
Converting to a binary file is actually the best route in my opinion.

Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 7th Aug 2014 15:43
Absolutely. A binary format (particularly one designed such that there is little to test for) should load >100X faster (random guesstimate) if done correctly. Maybe a bit slower in AppGameKit, though.

JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 7th Aug 2014 16:14
Yes - But bear in mind that it's much harder to change the format later...

-- Jim - When is there going to be a release?
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 19th Aug 2014 12:30 Edited at: 19th Aug 2014 12:30
So yes, I AM going to spam most of the threads I have created recently with a message:

VOTE FOR RTA! The voting is down the bottom of the page and does not require a login.

Rush To Adventure is an awesome retro Zelda-style 2D platformer made with AppGameKit that's already doing really well on Android mobile devices and Ouya. It's created by Digital Awakening, who has put a huge amount of work into this game; it's well worth checking out and VOTING FOR. Go. Now. Vote for RTA!

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Aug 2014 19:08
I was thinking original zelda style, it's more like legend of zelda 2 with the side-scrolling. Looks cool though, I like retro.

Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 20th Aug 2014 04:11
Quote: "I was thinking original zelda style, it's more like legend of zelda 2 with the side-scrolling. Looks cool though, I like retro."


I've never played any Zelda game - I just saw it compared to one or other Zelda, so I did the same.

Karnage
9
Years of Service
User Offline
Joined: 5th Dec 2014
Location:
Posted: 17th Dec 2014 11:55
Hi Clonkex,

Quick question if I may, does this tmx loader work with AGK2?
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 17th Dec 2014 22:46
Quote: "Hi Clonkex,

Quick question if I may, does this tmx loader work with AGK2?"


Good question. The answer is... no idea! If you've got AGK2, go right ahead and give it a try

Actually now that I think about it... it might not, since they changed how some things work with arrays and the like. If I can find some time I might whip up an AGK2-specific version later

Karnage
9
Years of Service
User Offline
Joined: 5th Dec 2014
Location:
Posted: 18th Dec 2014 10:29
Thanks Clonkex, I gave it a go but as you would expect, it is broken at the moment with the following compile errors:-




I would try to fix it, but I am new fairly to programming (I know a small amount of Javascript) and also AppGameKit basic so would proberbly break it further lol

Would love to see this working with AGK2, so if you did get some time at some point to fix it up it would be awesome Or if their are any pointers you or anyone could give where I could try to assist in fixing it as a learning experience that would be awesome too
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 19th Dec 2014 06:08
Quote: "Thanks Clonkex, I gave it a go but as you would expect, it is broken at the moment with the following compile errors:-"


Ah that's good, it's just what I thought it would be. Very easy to fix, I'll do it in a second

The reason for the error is that Paul changed how the "mod" operator worked in AGK2. IIRC, in AGK1 you could do this:



...whereas in AGK2, you have to do this:




----------------

Ok I can't fix it just yet, had to create a new topic on the forums about how the AGK2 arrays work, gtg right now back later

Wilf
Valued Member
17
Years of Service
User Offline
Joined: 1st Jun 2006
Location: Gone to Unity.
Posted: 5th Mar 2015 19:58 Edited at: 5th Mar 2015 20:04
Awesome code, but the string parsing is a bit naive. Searching for 1 character long strings is a bit dangerous if that character is used previously in the xml string. e.g, you have a Tiled object that looks like this:

You want to retrieve the position values x and y of this waypoint:


x will return correctly, y will return 0 because it searched for the character 'y' and found the 'y' in 'waYpoint'.

The solution is to search for terms like this:



(notice the 'y=') and then in xml_GetAttribute$(attributes$, attname$)
change

to


Twitter: @itanican
Facebook: https://www.facebook.com/PushdownGame
Website: www.push-down.com
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 5th Mar 2015 23:38
Quote: "Awesome code"


Thanks!

Quote: "but the string parsing is a bit naive"


That's because I didn't write the XML parser lol

Quote: "x will return correctly, y will return 0 because it searched for the character 'y' and found the 'y' in 'waYpoint'."


Yes, I see what you mean. I'd never even looked at the XML parsing code so never noticed. Thanks for pointing this out. I may find the time today to fix this problem and upload a new version, but I'm planning on being pretty busy with other stuff

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Mar 2015 01:15
Quote: "but the string parsing is a bit naive"

Quote: "x will return correctly, y will return 0 because it searched for the character 'y' and found the 'y' in 'waYpoint'."


It shouldn't. It should take into consideration the quotations and equal signs automatically to properly find the attribute names. If not, I can fix it to do so.

Haven't you tested this example?


"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Wilf
Valued Member
17
Years of Service
User Offline
Joined: 1st Jun 2006
Location: Gone to Unity.
Posted: 7th Mar 2015 20:45
Certainly have, spent a while debugging it too cos it's a pretty insidious bug

Twitter: @itanican
Facebook: https://www.facebook.com/PushdownGame
Website: www.push-down.com
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Mar 2015 01:12
Looks like a made a slight oversight with the parser, oops


"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 10th Mar 2015 02:02
well hope you guys get that fixed. If not you can use other parsers out there I used rapid xml to get the x and y codes for the parser I used. So I not really sure how your parser works. I haven't tried your code. This is because I built my own program that gets information from tiled.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
paulrobson
9
Years of Service
User Offline
Joined: 22nd Nov 2014
Location: Norfolk, England
Posted: 10th Mar 2015 14:33
I just abandoned it altogether - used Python to read in the tile map data and RLE encode it. It is still under development but if anyone wants a look its at https://github.com/agkdev/library-tiles - at the moment just straight orthogonal tiles but it does allow multiple maps and windows.
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 10th Mar 2015 17:00 Edited at: 10th Mar 2015 17:02
paul that one is limited it only loads one tile map according to documentation.I shared my c++ version of the loader and it load multiple maps and layers. Well it was made by someone at MIT though so I guess it will work.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
paulrobson
9
Years of Service
User Offline
Joined: 22nd Nov 2014
Location: Norfolk, England
Posted: 10th Mar 2015 18:30
Yep, I gathered that the other one does. I wanted something that worked in Tier 1
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 10th Mar 2015 21:57 Edited at: 10th Mar 2015 22:38
That is why I exported the tiled maps in a format that both tiers can read.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Mar 2015 22:51
I think performance-wise, it's better in the end to have the file exported into a binary format to fit your own needs rather than deal with the impact of a text parser.


"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 12th Mar 2015 02:12
that is why I exported the data in agk file format so It actually is a lot easier to deal with in the end.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.

Login to post a reply

Server time is: 2024-05-05 20:58:44
Your offset time is: 2024-05-05 20:58:44