Data driven design and Kyra

Help
2006-02-09
2013-06-04
  • Gianfranco Berardi

    I'm merely toying with the idea, so I apologize if it seems I haven't given too much thought to it.

    Basically, I know that you normally include your header created by krencoder when you build your project.  The header simply seems to hold values corresponding to the sprites in the .dat file. 

    But what if I want to make a game that allows you to create your own dat files?  Would you need to rebuild your entire app with the new header?  Obviously I could script it to load in the .dat, but the header can't be included in an already-built project.  There isn't anything else to the header file so I imagine you could probably just load in the values specified and use them in your own code.  You'd probably load them in a map or vector or something. 

    Or is there some already-provided-for way that I didn't see?

     
    • Lee Thomason

      Lee Thomason - 2006-02-09

      Yep - every message that takes an ID:

      void SetAction (U32 id)

      also has a string form:

      void SetAction (const std::string &actionName)

      So it can be:
      sprite->SetAction( RUN );
      or
      sprite->SetAction( "RUN" );

      I actually prefer the string form, myself. And it allows for the kind of dynamic naming you are talking about.

      Although that is an unusual approach - usually you want to keep the names the same and just change the assets. In this case, that means fixing the names and created new .dat files with the same object names, although there is nothing wrong with using dynamic names loaded from another source.

      lee

       
    • Phuoc Can HUA

      Phuoc Can HUA - 2006-02-14

      I hope that I've understood your issue... basically you want the users to be able to load their own dat-files on an existing program, right?

      I've done similar thing (skin for my program). In that case, I can't compile my project with a static dat-file. I have to make sure that the program is able to read and PROCESS external information ( from dat-file). An issue has been addressed sometime ago:
        https://sourceforge.net/forum/forum.php?thread_id=1111931&forum_id=149869

      At the end, I 'hide' additional information in the tags for the sprites. The modified source codes is available at:
        http://www.huaonline.com/softwares

      Unfortunately, there's no proper documentation. I'm thinking to blog the idea for what I've changed. But there' still not enough time  :-(

      HTH
      Phuoc Can HUA

       
      • Phuoc Can HUA

        Phuoc Can HUA - 2007-05-10

        Finally, I've got a chance to minimize my existing project to a demo program:
          http://sourceforge.net/projects/sdl-skin
        In my case, I'm allowing users to define their skin with XML-files and create their own dat-file.

        I use "empty" sprites to embed information in the dat-file (as suggested in https://sourceforge.net/forum/message.php?msg_id=2670718\), e.g.
        <Definition filename="dummy.png">
          <Sprite name="skincare-version">
            <Action name="1.01">
            <Frame />
            </Action>
          </Sprite>
        ...

        I also use them to define the position of a group of buttons (sprites):
          <Sprite name="group">
            <Action name="player.playbuttons">
            <Frame deltax="0" deltay="0" />
            </Action>

        The action name is used to define a group name. The button belongs to this group is defined as:
          <Sprite name="PUSHBUTTON004">
            <Action name="player.playbuttons|PLAY">
            <Frame x="15" y="20" width="220" height="90" hotspotx="0" hotspoty="0" />
            </Action>
          </Sprite>

        If you change deltax/y above you can move all buttons with:
            <Action name="player.playbuttons|*">

        I hope that I'll be able to write a proper document for that one day. But basically, I want to show is that I use "empty" sprite to encode additional information. Also, more information is encoded in the Action name (seperated by '|')

        Phuoc Can HUA

         
    • Lee Thomason

      Lee Thomason - 2007-05-11

      Phuoc Can HUA --

      Great to see the project go up! Congratulations!

      I'm not sure this is directly applicable to what you want to do, but you can embed binary and text data in the .dat files.

      http://grinninglizard.com/kyra/kyraxml.html#userdata

      lee

       
      • Phuoc Can HUA

        Phuoc Can HUA - 2007-05-12

        Hi Lee,
        Thanks a lot.

        Indeed, I did consider external text file. But then the user defined information has to be splited in different files (https://sourceforge.net/forum/message.php?msg_id=2670794)
        There's also a technical issue. I have to parse the external file. Also, if the information is defined in the XML-file error can be already found in encoding phase.

        Of course, the perfect solution would be to enhance the encoder to convert new tags. Since I didn't understand the encoding part of Kyra I decided to go with the quick & dirty solution, i.e. using dummy sprite to carry additional information, not very efficient  :-)

        Phuoc Can HUA

         

Log in to post a comment.