Do this and that, at the same time...

This is a discussion on Do this and that, at the same time... within the C++ Programming forums, part of the General Programming Boards category; Hi everyone, I wonder if anyone know of a way to do more that one thing at a time, in ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    80

    Do this and that, at the same time...

    Hi everyone, I wonder if anyone know of a way to do more that one thing at a time, in a c++ console app.
    I'm writing something that's supposed to become an ASCII-game some time in the near future. I have no difficulties
    with moving a letter around on the screen but since the program is waiting for keyboard input it won't do anything
    else at the same time.
    Let's say I want to make an ASCII version of pacman, how can I get the "ghosts" moving and at the same time
    being able to control pacman ?

    Any help or link to a tutorial will be greatly appreaciated.

  2. #2
    Registered User
    Join Date
    Mar 2005
    Posts
    26
    create a continuous loop that does the stuff you want and then reads the keypress. there's a function in curses that reads the key without pausing, i believe.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    80
    Thx for the reply. I forgot to mention that I'm on windows (xp) and that means I don't have curses

  4. #4
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Check out http://msdn.microsoft.com/library/de...nckeystate.asp,
    remember to include the <windows.h> header if you use that

  5. #5
    Registered User
    Join Date
    Sep 2004
    Posts
    80
    Thank you! This will surely be of great help.

  6. #6
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,680
    Excellent console programming tutorial for Windows:
    http://www.adrianxw.dk/SoftwareSite/...Consoles1.html

    gg

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21