Results 1 to 2 of 2

Thread: Key Sequences

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    837

    Key Sequences

    Does anyone know how to detect if a sequence of keys has been pressed, like the moves in say mortal kombat. I don't necessarily need someone to write some code, but if you want to it might help. What i really want is an explanation of how it can be done.

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    You'd probably want a set time, in milliseconds, of how long the user can wait before pressing the next 'combo' move. We'll call this Delay.

    Use the GetAsyncKeyState API on a timer or Do..DoEvents..Loop sequence to get info on all of the keys.

    Below is some pseudo-code, not ready for VB:

    Code:
    Do
          Put current keystate Array() into LastKeystate Array()
          GetAsyncKeyState calls for the key(s) you are monitoring.
          Populate a keystate Array()
          If there is another key in the sequence(s) pressed, and (GetTickCount - Varb <= Delay) Then fill in combo state or execute combo
          Varb = GetTickCount
          Other Routine(s)
       DoEvents
    Loop
    I hope this gives you a somewhat vague idea of how to do what you are looking for.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width