keystrokes related question..

This is a discussion on keystrokes related question.. within the C Programming forums, part of the General Programming Boards category; I'm working on a Snake like game, and I wanna direct the snake to move as I press the keys... ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    4

    keystrokes related question..

    I'm working on a Snake like game, and I wanna direct the snake to move as I press the keys...

    When the game start, the snake moves to the right.
    The condition looks a bit like this:

    while (!kbhit())
    {
    moveright();
    }

    i want to add something, so that whenerver i press lets say 'a', it'll change to the function of movedown...

    how can i do that?

  2. #2
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    use conio.h -- getch();

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    4
    getch() would halt the program
    i dont want to do that...

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    4
    its working
    really nice, thanks mate

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A question related to dynamic memory allocation
    By spiit231 in forum C Programming
    Replies: 2
    Last Post: 03-11-2008, 12:25 AM
  2. Design layer question
    By mdoland in forum C# Programming
    Replies: 0
    Last Post: 10-19-2007, 04:22 AM
  3. Yacc question related to %type
    By g_p in forum Tech Board
    Replies: 0
    Last Post: 05-31-2007, 09:55 AM
  4. Question related to getpid and getppid
    By g_p in forum C Programming
    Replies: 4
    Last Post: 12-18-2006, 10:35 AM
  5. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 08:22 PM

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