Game Dev Diary: FR v0.20

Game Dev Diary: FR v0.20

Just a quick update, but a milestonious (that’s a word) one this time. Having set the foundations for paired tiles in v0.19, I’ve now implemented a way of making warp tiles work!

There’s a slight kludge to it, but not one that should cause a problem. See this code:

 p = tile.pairn
 player.x = objects[p].x*8
 loc.x = player.x-64
 player.y = (objects[p].y-1)*8
 loc.y = player.y-48

As mentioned before, each object has .n and .pairn attributes, with .n being the object ID, and .pairn the object ID of the object it pairs with. With warps, this means that if you hit one you warp to the object with ID that matches .pairn. Make sense?

So what I’d hoped to be able to do, is easily refer to an object by its .n attribute. Something such as “find the object where object.n = currentobject.pairn”. I think this could be done with a foreach, but it so happens that .n actually matches the item number in the object array. No use for a general case, but fine for me – a bit of a kludge, and one that may return to bite me later, but we’ll see.

In order to test it out, I created a couple more warps, also paired. I’ve just realised that the way I’ve written my code I could actually have a loop of warps, so 1->2->3->4->1, if I wanted. That’s pretty cool, I suppose, and may be useful later on.

You’ll notice that when the little man “materialises” (I’m going to have to make this a bit better animated, but that’s not important just yet) he’s a tile above the warp. This is so that he doesn’t immediately warp again! I could work out a way of preventing auto-rewarp, I suppose? That’s for the list.

You can “play” what I have so far here:

[includeme src=”” frameborder=”0″ width=”400″ height=”400″]

To do:

  1. Make switches open and close doors
  2. Make an actual game
  3. Graphics (still)
  4. More stuff

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.