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 / TMX map loader

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th May 2013 08:06 Edited at: 7th May 2013 08:29
Since my DBP importer didn't get much attention in program announcements, I thought I'd post my AppGameKit version here. Took about the past 6 hours to write. Demo attached complete with all source code for the library.

All 3 map types are supported: Orthogonal, isometric rotated, and isometric staggered.

Hold the left mouse button down to move the map around. Keys 1-4 will load different maps, with the zelda map taking the longest to load.



I did some loading tests between my AppGameKit and DBP versions. I like AppGameKit! The load time for the large zelda overworld map was almost 10x faster! But that's probably mostly due to the different xml parser I made for it.



The commands work using a tile index to reference locations on the map. If you want grid coordinates, the following equation will work regardless of map type.




Commands:
tmx_LoadMap(string filename)
tmx_FreeMap()
tmx_DrawGridTile(int tileIndex, int red, int green, int blue)
tmx_SetMapPosition(int x, int y)
tmx_SetMapVisible(boolean)
int = tmx_GetTileIndex(int layer, int worldX, int worldY)



Unlike the DBP version, this one doesn't store the collision boxes from the map file but can be easily added.

"You're all wrong. You're all idiots." ~Fluffy Rabbit

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th May 2013 14:54
Phaelax, thanks! I'll be testing this later I was going to write one myself but knowing your usual level of coding I know I don't have to


this.mess = abs(sin(times#))
Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 7th May 2013 21:01
Thanks Phaelax! This is a very welcome addition to the AppGameKit codebase. Can't wait to test it! (But that might take some time since I became a father last saturday. An incredibly happy event, but disastrous for my 'spare-time hobby)
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 7th May 2013 21:12
Be sure to add it to the official agk codebase

I remember Learning to code with your rts sample on dbp

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th May 2013 22:47
Quote: "Be sure to add it to the official agk codebase "

Is that the stickied snippet thread?

"You're all wrong. You're all idiots." ~Fluffy Rabbit
kslam212003
11
Years of Service
User Offline
Joined: 10th Dec 2012
Location:
Posted: 8th May 2013 04:15
@Phaelax Where can I download the Tmx map loader ?
kslam212003
11
Years of Service
User Offline
Joined: 10th Dec 2012
Location:
Posted: 8th May 2013 04:22
I found it. It's the tier 1 version.

Do u have the Tmx map loader tier 2 version ?
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th May 2013 06:06
No, I haven't messed with Tier 2 at all. But I'm making a DBP plugin right now

"You're all wrong. You're all idiots." ~Fluffy Rabbit
spasski
AGK Backer
11
Years of Service
User Offline
Joined: 2nd Jan 2013
Location: Amsterdam
Posted: 8th May 2013 22:42
Great job Phaelax!

I'm a bit new to AppGameKit and search the forum often for placement/tile editor tool as it speeds up making games like sidescrollers. I like the tool you posted here as it supports tiled layers but somehow I get an error when creating my own TMX files with TILED having more then one layer. The example proves multiple layers are possible in your code but I can't figure out why my own TMX file gives an error... Using the code with one layer in the TMX runs ok.

the error I get when having 2 layers:

Failed to clone sprite, Sprite 0 does not exist at line 357 in tmx_engine.agcf

thanks for helping me (and others perhaps)

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th May 2013 03:06 Edited at: 9th May 2013 03:10
Can you send the tmx file and tileset image and I'll see what's going on.
My guess at the moment is that it isn't loading the tileset image and therefore the base sprite isn't being created.

Not sure I stated this, but the file must be saved in XML format and the TSX tileset is not supported (though it could be implemented easily). And no Base64, gzip, or zlib.

I've written a Base64 encoder/decoder in DB, so I think that part would at least be possible in the future.

"You're all wrong. You're all idiots." ~Fluffy Rabbit
spasski
AGK Backer
11
Years of Service
User Offline
Joined: 2nd Jan 2013
Location: Amsterdam
Posted: 9th May 2013 10:38
I just found out that when using the "make duplicate layer" button to create a new layer in Tiled, the issue has gone
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 9th May 2013 10:43
Quote: "Is that the stickied snippet thread?"

the same as for dark basic Classic and db pro they added agk there also

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
spasski
AGK Backer
11
Years of Service
User Offline
Joined: 2nd Jan 2013
Location: Amsterdam
Posted: 9th May 2013 11:02
oops, need to correct previous post: issue does not occur anymore when all tiles are filled in the second layer (so no tile gid id's in the xml with value 0)

still, a bit strange as the example file does has gid id's with value 0???
haliop
User Banned
Posted: 9th May 2013 12:24
very nice ... except zelda map took forever to load..
really liked the isometric!

3d point in space
15
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 9th May 2013 16:52 Edited at: 9th May 2013 16:52
haliop I have a c++ tmx loader in the forums it is a year old but it does the trick. Phaelox code looks good I might use it as an export for my editor to my sprite engine. Since I am not that good at basic part of agk.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 10th May 2013 07:43
Is TMX "Tiled"?
Cause i have already done a loader for maps in Tier2 iOS.
It work with JSON and not with XML.

Long life to Steve!
haliop
User Banned
Posted: 10th May 2013 10:33
3dpis you must must learn basic its amazing.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th May 2013 20:22
Quote: "Is TMX "Tiled"?
Cause i have already done a loader for maps in Tier2 iOS.
It work with JSON and not with XML.
"

Yes.

I'm working on a plugin for DBP that will hopefully support all the compression as well. I'll likely release the source code and that should make it easier for anyone who wants to do this in Tier2. Did you use an existing library for the JSON?

"You're all wrong. You're all idiots." ~Fluffy Rabbit

Login to post a reply

Server time is: 2024-11-24 13:33:57
Your offset time is: 2024-11-24 13:33:57