Input logging and playback [SOLVED]

edited October 2011 in Help request
Hello. For my senior project, our team of three programmers wishes to make a top-down arcade shooter. One of the features we wish to implement is a replay feature. This feature would involve capturing input every frame and playing it back.

We know how we'll capture the input pretty easily; toggle bits representing each key and store the result per frame. The question is: how do we replay it? Is there a way to get our program to send orx input as if it were a keyboard? For example, if one of the input strings was interpreted as the player pressing up, left, and fire at the same time, how would we get orx to act as if those buttons are being pressed?

Comments

  • edited October 2011
    Hi!

    Well, before I can help with that part, let me propose you an alternative and if it doesn't suit you we'll try to find a solution to make it work your way.

    As orx has an input abstraction layer I'd suggest we use it. That means that you'd be able to easily record inputs, whether they come from keyboard, mouse or joystick and you'll still be able to allow user input customization (in-game or offline, at your convenience).

    If you go down that road, you simply need to register an event handler to listen for the orxEVENT_TYPE_INPUT events.
    Then you'll get notified of orxINPUT_EVENT_ON/orxINPUT_EVENT_OFF for all the inputs that you defined.
    When you get those notifications you can then store a list of timestamp + input name.
    When you want to do the replay all you have to do is to unlink the current physical input (by switching to an empty input set, for example) and activate the inputs yourself over time by calling orxInput_SetPermanentValue()/orxInput_ResetValue(). That should do the trick.

    If you still prefer going with storing physical inputs, assuming you're using the orx's input system, you'll then have to look for your physical key and find the matching input and then activate it.

    If you're reading directly values from the keyboard module, things will get much more tricky and you'll lose all the flexibility the input module brings you. :)

    Hope this helps!
  • edited October 2011
    Oh wow. Thanks for that, I was wondering what a good use for that set permanent value function was.
    Question answered. You, sir, rock amazingly.
  • edited October 2011
    Ahah, thanks for the praise but we'll see about that when you get something that works! ;)

    I should probably add a tutorial for input recording on the wiki. Or maybe, if you feel like it when you've done yours, you could write such a tutorial there (no pressure of course!)?
  • edited October 2011
    We'll see. I'd love to write a tutorial if I get time, and get it working. I think I see how it can be done, though.

    This is just a feature we'd like to implement, but we won't if we don't have enough time. We're just planning everything we want to so that if we get far enough to implement them.

    That, and when I start my own project, I want it to have a replay function.
  • edited October 2011
    No worries, as I said, there's no pressure nor obligation.
    I was just pointing out that the wiki was there if you wanted to share some of your knowledge at some point. :)
Sign In or Register to comment.