Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Monday, 21 July 2008

Working at Prince of Persia

Hi all,

As some of you know, I am in the final development stage of the Prince of Persia project, and as result of it, I am quite busy right now (and I will be until it is released).

I like the last months of the projects, I usually work like crazy, but it´s the moment when you see everything coming together for the first time since the start of the project, and it is really beautiful.

There are some cool Prince of Persia videos in GameTrailers, even if it´s not your type of game, I think it does worth a click to see them.

Check it here : http://www.gametrailers.com/game/6739.html



That´s it, just a quick post to show signs of life!!!

J.

Sunday, 16 March 2008

XML based script for use in tools

Some months ago, I was asked to find a way to store user profiles and other internal application data so it could be saved for later use and shared between the application users, not a big amount of information, but enough to avoid standard .ini files.

I had been using TinyXml in the past, but I do not really like the interface to access or store information (not really a problem of TinyXml but the xml itself), so I decided to use it but also to implement a small layer over it, to have a better interface from the application and at the same time hide as much as possible the standard xml usage.

Some small issues appeared though, as I had to encode regional characters into the xml files, so UTF-8 was selected as the xml encoding. I created a couple of functions to convert from ansi to utf8 and from utf8 to ansi, so save standard local text was possible (this is not intended to be a unicode universal conversion tool, but with few changes it can be used with any language and codepage).

Once the encoding problem was solved, I started to work on the intermediate layer, to enable the applications to store and retrieve data without any xml knowledge and doing it with the less possible amount of effort (the objective was to allow users to store and retrieve data, not to force then to learn the xml internals).

The result is a small class called DataScript (the name clearly indicates the intended use, it is not a script for decision making, it is just for data storage).

As a small example of use, look at this code to store and load some bits of information:

<code>

****** SAVE ******

DataScript root;
{
    DataScript usersDataSection = root.addSection("USERS_DATA");
    for (int i=0; i<mNumUsers; i++)
    {
        DataScript userSection = usersDataSection.addSection("USER");

        userSection.setString("NAME", mUserData[i].mName.c_str());
        userSection.setUInt("ID", mUserData[i].mId);
    }
}

root.saveFile("DataScriptTest.sb");

******* LOAD *******

DataScript root;
if (root.loadFile("DataScriptTest.sb"))
{
    DataScript usersSection = root["USERS_DATA"];
    int numUsers = usersSection.count();
    for (int i=0; i<numUsers; i++)
    {
        DataScript userData = usersSection[i];

        sUserData * user = mUserData.addUser();

        user->mName = userData.getString("NAME", "");
        user->mId = userData.getUInt("ID", 0);
    }
}

****** XML File generated *******

<?xml version="1.0" encoding="UTF-8" ?>
<Root>
    <USERS_DATA>
        <USER>
            <NAME Str="Jaico" />
            <ID UInt="1001" />
        </USER>
        <USER>
            <NAME Str="Cherno" />
            <ID UInt="2002" />
        </USER>
    </USERS_DATA>
</Root>

<code/>

Feel free to contact me if you need something like this, I will be happy to help in any way my limited free time allows me. I still have to search a place to store it and post a link to it, but in the meantime I can send it by email to anyone interested, just send me an email to cherno.olivares at the google mail system.

And this is all for this weekend, I have a really busy months in the horizon, but I will do my best to continue writing some articles.

Have a great day!

J.

Monday, 2 July 2007

This blog is starting... be patient

Dear bloggers,

During the following weeks I'm going to write a bit about real c++ projects I'm working on.
I will cover different programming areas, from GUI to game AI or game architecture.
Some examples that will come soon are :
- A good coding standard
- User resistant init/done pattern
- Dynamic software architecture and tools needed to implement it :
..........- Cheap RTTI
..........- Interfaces, exporting and importing functionality with no type dependencies (apart from the interface itself)
..........- State based machines : Easy and versatile implementation
..........- State stack
..........- Messaging systems, channel or message oriented
..........- Script system for in-game use (to allow data driven designs)
-Some FrontEnd tools
..........- XML based script : A fast and easy script for tools
..........- Class delegates, or how to store and call class member pointers from other classes
..........- Property based Frontend / Gui
..........- Remote Frontend for use at diverse software applications


Try to enjoy the reading as much as I'm going to enjoy writing it!

Some feedback would be appreciated if you are interested on any subject.

Cheers!

Cherno