Sunday 23 June 2013

Proper update soon

I'll be doing a proper post again soon, this is just a quick one so I can share something that was rather exciting to me.
Recent advances in the engine have been:
  • Collectible items and player inventory / wallet
  • Moving objects (basis for enemies and NPCs)
    • Different movement behaviors (because absolute random movement is awful)
    • Option to interact among themselves (objects picking up collectible objects or pushing pushable objects)
  • Control handling optimisation
I spent pretty much the entire weekend rebuilding the way input is interpreted which is surprising more complex than I had imagined; how do you handle a situation like [up arrow down] -> [right arrow down] -> [up arrow up] -> [left arrow down] -> [left arrow up]? The player should now be moving right and all other instructions should have either ceased or been ignored but this is not so simple especially when JS interprets a held key to be repeating constantly. It's a typhoon of key input and the filtration is hell if preventing controller latency is your goal.
It's in a good place now and I feel like it only required minor improvement but this isn't so interesting to you guys since you can't play with it yet to feel the effects of the change.

What I was going to share was this: it's a screenshot I took this morning on the train after I accidentally introduced a [now fixed] bug into the teleporter code.
The only reason this was so exciting to me is because it so resembles the "storm-of-unwanted-tiles-from-the-sprite-cache" style bugs from the NES era:
See what I mean? No? Oh well, I liked it.

2 comments:

  1. that screenshot is amazing. Btw I believe the solution to your js input problem is something similar to a debounce filter in electronics. Essentially a timer that only allows a single input to be registered per interval.

    ReplyDelete
    Replies
    1. Yeah, that's part of the problem. Something like:

      If (!keyDown)
      {
      keyDown = true;
      // Stuff
      }

      So it kinda enters the function and "closes the door behind" but there are many layers of complexity added, one of which is that number of keys down often doesn't balance out with number of keys up since they're only counted if the pane has focus etc. Getting him to move is easy but getting the controls to "feel good" is quite hard and I've always been very fussy when it comes to good controls.
      I'm sure server lag will be a much bigger problem but getting it right at the client side is important, too.

      Delete