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 / XML Parser for AGK Tier 1

Author
Message
Red Eye
15
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 3rd Jan 2012 15:34 Edited at: 3rd Jan 2012 15:38
Hey,

We have been working on our 2D Game Engine, EpicCTF, in AppGameKit Tier 1. Altough for our level editor, we had to use some sort of file format. We knew we wanted it to be simple to read and universal. It was clear what it should be using, the XML format. And we know some people on the forum have been asking for an xml parser. So here it is.

It is able to read something like this:



You can find indepth information about this, on our blog:

blog.codepard.com

We explain how to use it, and what it is able and not able to do.
We also give an example, to load the data into your app.

We attached the xmlParser.agc to this post.

We are still updating it as we go on with the engine, i am sure there are some good optimization possible.

You can use it as you wish. Some credits to the codepards would be cool! You can always like us when you feel like it! At http://www.codepard.com/ !

Cheers,

Attachments

Login to view attachments
Red Eye
15
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 4th Jan 2012 18:35
Anybody tried it out? Is it any usefull?

Cheers,

Nokiaqd
14
Years of Service
User Offline
Joined: 31st Aug 2009
Location:
Posted: 4th Jan 2012 20:00
Red Eye Do not worry very useful piece of code I need in the future is this parser, at this moment I can not try it. early, and many thanks for their work.

badablog.ru - bada developer
Wilf
Valued Member
17
Years of Service
User Offline
Joined: 1st Jun 2006
Location: Gone to Unity.
Posted: 11th Feb 2012 16:14
Sadly it doesn't work, reading just spaces and NULL from the xml file.
Wilf
Valued Member
17
Years of Service
User Offline
Joined: 1st Jun 2006
Location: Gone to Unity.
Posted: 11th Feb 2012 17:27
Here's a test project attached that outputs a logfile to MyDocuments/AGK

The if statement eleName$ = "object" is never true as xml_getElement(iterator as integer) doesn't parse the string properly.

Attachments

Login to view attachments
Greenster
19
Years of Service
User Offline
Joined: 3rd Feb 2005
Location: US ©
Posted: 11th Feb 2012 18:44
xcode, J2ME, J2ME->Darvik all have XML engines, just like another useful set of functions, sockets(or HTTP subset), it's not implemented.

I actually found another way more powerful tool that generates intermediate code(flex, xcode c++, j2me, python, Java) from a BASIC that also doesn't have this or realistic networking.. I really don't get it.. it's pretty hard to do social platforms without any social functionality..
Canadian Mark
12
Years of Service
User Offline
Joined: 28th Jan 2012
Location:
Posted: 12th Feb 2012 01:01
This is very interesting and falls in line with what I would like to accomplish for my current project. I would like to use an external file to create my levels since the core mechanics and classes are built
and all I would need to do would be populate my arrays of sprites, elements, sounds and behaviours The idea being to move onto level design with minimal code to load each one. I was thinking of creating my own format inside .txt files but if I could use xml and a schema that would make them much easier to design using various xml tools as well as being more human readable.
sparkart
12
Years of Service
User Offline
Joined: 2nd Nov 2011
Location:
Posted: 12th Feb 2012 13:15
If only we had plugin support.
Red Eye
15
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 12th Feb 2012 13:17 Edited at: 12th Feb 2012 13:20
Wow, totally forget about this, sorry.

Let me see...

@Wilf:

1. The parser doesnt support one lined XML files.
2.
Quote: "`seriously - the app should exit here if that element is ever found "


You are ending when it is found, so why? Or is it me being stupid. haha.

3. I attached EpicCTF project file, it totally works there. Maybe you can check out your error. Some things in the game itself isn't totally working, (parralax walls) so dont mind that.

EDIT: You can use all media in the file attached if you want in your own games, just credit me a bit .

Cheers,

Attachments

Login to view attachments
Wilf
Valued Member
17
Years of Service
User Offline
Joined: 1st Jun 2006
Location: Gone to Unity.
Posted: 13th Feb 2012 22:14
I had a fun weekend playing around with it, figure out that you weren't defining pos_b anywhere inside xml_getElement so I added


and a function to remove tabs at the beginnings of lines. Cool stuff
Red Eye
15
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 13th Feb 2012 22:28 Edited at: 13th Feb 2012 22:32
Omg thats kinda dumb of me, yeah pos_a should have been pos_b ofcourse (so it matches the reach of the if statements). What was I... drunk or something?

Thanks for the notice, will fix it on the blog .

Does the parser reads tabs differently from spaces? Thought my replace function would have fixed that.

Thanks for testing! Have a .

Cheers,

Wilf
Valued Member
17
Years of Service
User Offline
Joined: 1st Jun 2006
Location: Gone to Unity.
Posted: 13th Feb 2012 22:56 Edited at: 13th Feb 2012 22:56
Heh, no problem. It was fun.

So how would you handle a nested xml file? I'm trying to read data generated by Tiled which outputs an xml file renamed to tmx. I've attached an example.

Attachments

Login to view attachments
Red Eye
15
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 14th Feb 2012 03:14 Edited at: 14th Feb 2012 03:19
The nested data example in your tmx file can be written like this:

map > tileset > tile > properties > property


This is indeed a new concept but it can easily be covered with the current commands:

The easiest solution:

- All of the elements (map, tilset etc.) are returned by calling xml_getElement().
- You can do a switch/case upon each level. So in this case your map level has two sublevels, so you would create a switch for thetileset and the layer sublevel. Your tileset has a sublevel for tile and image, you would need to create a switch for tileset and two cases for the image and tile sublevels. And you do this for all Levels > Sublevels. Based on that you get your data from each level.

BTW:

I am pretty sure Tiled uses the same image element with the same attributes in different nested situations, for these returning elements I would make a function that handles that on itself. So you create your own little library made for Tiled his way of exporting.

Cheers,

Wilf
Valued Member
17
Years of Service
User Offline
Joined: 1st Jun 2006
Location: Gone to Unity.
Posted: 15th Feb 2012 19:11
Quote: "- You can do a switch/case upon each level. So in this case your map level has two sublevels, so you would create a switch for thetileset and the layer sublevel. Your tileset has a sublevel for tile and image, you would need to create a switch for tileset and two cases for the image and tile sublevels. And you do this for all Levels > Sublevels. Based on that you get your data from each level."


and you're iterating through a new for/next loop inside every switch?

Login to post a reply

Server time is: 2024-04-18 19:45:51
Your offset time is: 2024-04-18 19:45:51