Thread: I really need help

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    4

    Unhappy I really need help

    i am stuck and darn stuck i am trying to make a kunar lander like this in c++

    Play LunarLander Game

    in this program i am stuck at the fireing rocket stage

    i need a function that tell me the duration i have pressed a key


    e.g
    i press "A" or any key it gives me the time from when i press A and leave it in millisecond

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well it all depends on your operating system and compiler, and whether you're writing a console or GUI program.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2011
    Posts
    4

    thnx for the rply

    i am doing this with c++,

    borland 5 or turbo 3.2

    windows xp & 7

    not gui console based

  4. #4
    The Dragon Reborn
    Join Date
    Nov 2009
    Location
    Dublin, Ireland
    Posts
    629
    use a game programming tool..like xna or allegro or ... (opengl )
    i assume it will be a pain in the butt to do it with command line
    You ended that sentence with a preposition...Bastard!

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Can either of those compilers generate win32 programs?

    If not, you should consider upgrading to something more in tune with your real operating system. Relying on backward compatibility will only get you so far...

    Win32 Console Applications 5
    With this, you can also add timing to see how long it took between various key events.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Jan 2011
    Posts
    4

    ?

    i have done my project to quiet an extent but am stuck am doing my bachlour so am stuck with c++...i cant seem to sove this issue

  7. #7
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    You won't get a WndProc in console mode but I think you can use GetAsyncKeyState(). If you can use that (I'm not sure b/c I almost never use console mode) then start a timer when it is down and stop the timer when it is up. Subtract the start time from the end time and you will know how long the key has been held down.

Popular pages Recent additions subscribe to a feed

Tags for this Thread