General Progress Update 2008-12-07

After being inspired by Kael’s detailed post I felt like revealing a bit of my engineering solutions that Neox is buildt upon.

The problem Kael faced at first is something I had faced as well, when you press a button like Escape/Back to get out of a menu it would trigger again instantly but for the new state which could be the general gamescreen and you’d have a main menu flickering on and off. I have made a translation class which is told to either use Xbox Gamepad input or a keyboard as its source and translates keypresses and stores them in a class that I’ve created myself - which the entire engine relies on in turn.

What this results in is that we can change the source from keyboard to gamepad, without having to change any of the engine code around, because they all rely on my homebuildt class which has one bit of information more than the ButtonState.Pressed / ButtonState.Released offers. Instead we have something like this:

InputState state = InputState.GetState(PlayerIndex.One);

if (state.Cancel.State == ButtonState.Pressed)
this.Quit = true;
state.Cancel.State = ButtonState.Released;

if (state.Cancel.IsHeld)
// do something interesting

The major differences can’t be seen here actually, but first off the most apparent change is “IsHeld” which basically acts as the “we’re still pressing this button, but we don’t wish to call it a new buttonpress all the time” so State can be set to not trigger any more calls for that button IF you want to, or you just let it keep it’s Pressed state until next time the engine fetches the inputstate, it will automatically be set as Released, and IsHeld will be true while you keep the button pressed.

This made it a lot easier to code the draggable areas in my mapeditor. The other good thing about making your own general translator class that handles input is that you can add timing to the buttonpresses. After a certain timespan (a few hundred milliseconds or so) the State of the button will be switched to Pressed for one cycle and keep on doing it every so-and-so milliseconds. Sort of like holding the button in Word, one letter gets registered and after a little while it starts repeatedly adding more of that letter.

No new screenshots at this time, I’m still working a bit on the background work behind the battle system, like how to determine the size of the group of monsters you face and their attributes depending on their levels.

Share This!
  • Digg
  • Reddit
  • Facebook
  • Google
  • Technorati
  • TwitThis
  • Slashdot

Tags: , ,

Leave a Reply

You must be logged in to post a comment.