Wednesday 9 May 2012

Guests!

With paths, it was time to see whether guests could be added. I had no idea how to add it, so it took a while to figure out how to approach the problem. This first attempt is all somewhat experimental. At the right is the first 'real' result, a small figure-like sprite appears at a path at the edge of the field. He follows the path, taking random directions until he gets bored (then he suddenly disappears).

Please note that some of this code is not committed, and never will be, in its current form. The reason why is as follows:

Motion is not fluent, he sort of jumps to a new position every few seconds. Also, he walks next to the path instead of at it. Another problem is that drawing figures is terribly expensive, because the data is not organized correctly.

He is also very much colourless, but that is intentional. The video blitter needs to be upgraded so it can perform recolouring while blitting.

While I am happy with this first result and I have learned a lot from this attempt, I have also decided to re-organize the code and data, so the program can have (hopefully many) more guests without costing a lot of CPU time.

4 comments:

  1. Very cool to see this progressing. Just shout when you are interested in getting some guest sprites!

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hello, Alberth!
    I'm wondering if the quest is not jumpping from position to position because of the main loop.

    Also, I presume that all objects in your game has a position defined by a number multiplied by the tile size. If so, this could be the reason of the quest walk next to the path. Maybe you subtract the current quest position by half of the tile size... making it higher up in the screen.(sorry for the bad english).

    Posting a video could be useful to get help with these motion issues.

    Well, good work!!!

    ReplyDelete
  4. Hi Felipe Ferreira (at least I hope that's your surname),

    Thanks for your post, and thinking along with me.
    The jumping guest may look weird, but it is in my opinion the smaller problem right now. The wrong data structure makes that rendering guests will take O(N**2) with N the number of guests. It means with twice as many guests, the amount of time to render goes up by a factor 4. Four times as many guests, gives a factor 16, etc. You don't want to think what happens with a 1000+ guests :p
    Once I realized this, I stopped working towards a nice smooth animation. However, I did want to let you guys (and girls) know that I am still working on this program, so I made the blog post before breaking the code, which will take several weeks (if not longer) to get back into some sane shape.

    What I believe is the cause of the jumpy behavior is that the guest does not redrawn often enough. The main loop runs at 33.3Hz, so that should be fine I think. Positions are integer numbers where a single tile (voxel, actually) is 256 positions (in x, y, or z direction). Tile size will vary somewhen in the future (so you can zoom in/out). Current size is 64 pixels.
    The guest walking next to the path is either the sprite offset being very wrong, or my base position being wrong, or both :)

    I have good hope I can figure out these details once the data structure problem has been fixed.

    ReplyDelete