As I said previously, this process wasn’t very efficient. So I rewrote large parts of the code for the conversion of NXT RPG XML data files.
All files have so far been placed in the same folder. So I decided to organize it a bit:
- [folder] “global” : Contains all XML files that is used throughout the game
- [folder] “graphics” : Contains all graphics used in the game
- [folder] “levels” : Contains all levels used in the game
- [folder] “shared” : Contains all XSLT files used for previewing/converting files
- [folder] “strings” : Contains all strings used in the game
- fileindex.xml : Contains a list over all game files
I wanted it to be possible to choose your own names, so “level42.xml” could instead be “Scary shopping mall.xml”. So fileindex.xml contains these names. It looks like this:
It should be rather straight forward.
- <gamestart> Filename of the file containing information needed for starting a new game.
- <gamedata> Filename of the file containing information about the game, the name of the game and such.
- <character_list> Filename of the file containing a list over all characters available in the game.
- <attack_list> Filename of the file containing a list over all attacks available in the the game.
- <level id=”x”> Filename of the file containing the level data. “x” is a number from 1 to 254 which is used to identify the level.
- <sprite id=”x”> Filename of the file containing information about the graphics used for level maps. “x” is a number from 1 to 254 which is used to identify the graphic sprites.
- <characters> Filename of the file containing information about the graphics used for characters.
- <string id=”x” > Filename of the file containing a list of strings. ”x” is a number from 1 to 254 which is used to identify the string list.
Issue in Firefox
This just doesn’t work that well in Firefox. Style sheets accessed by “../” are blocked so basically nothing shows up if you try to open it. There is more about it here.
You can work abound the issue by opening “about:config” and change “security.fileuri.strict_origin_policy” to false. I don’t like it, but I’m not using Firefox so I’m not going to use time on it. However if any knows about a fix where it isn’t needed to move the files, inform me about it and I might fix it.
This needed to be a bit more organized. Up to now I had created a folder which was called the same as the ID for the level sprites (so something like “1″, “2″ and so on…). Inside that folder was a image for each sprite, so quite a bit…
In NXT RPG however the graphics are stored in one .RIC file. So I wanted to do the same here so the file looks like this:
Together with the image there is a XML file like this:
- <filename> The filename of the image containing the graphic.
- <type> The type of graphics. This can contain one of two values. “bg” is used for level sprites and “characters” is used for character sprites.
- <id> The ID of “bg” graphics. If <type> is “characters” this value must be “0″.
- <sprites> The amount of sprites contained in the image.
- <size_x> The size of each sprite in pixels. All sprites are quadratic at this point.
Implementation in HTML and CSS
An empty <div> is given a class called “[type][id]_[number]” where “[type]” is <type> (“bg” or “characters”), [id] is <id> and “[number]” is the sprite you want. An example could be “bg1_4″ if you want the sign sprite in the image above.
The CSS is created dynamically and looks like this:
background-position: -40px 0px;
A “.bg1_x” selector is created for each value of “x”
Those were main reason for rewriting it all. In Opera 10.50 beta it got corrupted if the HTML file became too large. Well, it really was large from the start, but most of it was just level previews that where repeated. So I wanted to remove those of course. (It didn’t work properly in IE either, but who cares…)
I don’t fell like writing more right now, so I will make it short.
Every level in fileindex.xml is created and assigned a (html) id based on the level (XML) ID. Then some CSS is assigned dynamically to connect the Events with the correct level preview. I will update this part later…
There is still a few things to get done, but most of the functionality is already done.
Any suggestions are welcomed.