http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to captue enter, up, down, left, right and Fx




If u're usin' Windoze zen u gotta use tha GetMessage func. to receive
the user'z key stroke. In plain ol' DOS, getch() does tha job
perfectly. it returnz tha ASCII code. The arrow keyz in DOS return 2
charectors: the first charector is a space (i think) the next charector
is one of GHIKLMNPQ, which are respectively for the numeric keypad from
top left to bottom right. Since u say u're using OpenGL... u can't use
DOS unless u're planning to use GCC or DJGPP with Mesa which has OpenGL
support for DOS.

so ultimately u're code should be (in DOS):

char c;
while(!kbhit());

c=getch();
if (c==13) // do code fer <Enter> key. This is a normal            //
key, it returns only one charector.

if(kbhit())
{
 c=getch();
 switch(c)
 {
  
  case 'H': // do code for up arrow key
  case 'K': // left
  case 'M': // right
  case 'P': // down
    .       // similiarly fer tha oth' keyz.
    .
    .
 }
}
  

--- AcidNaught <luisfertv@geocities.com> wrote:
> Hello everyone!
> 
> 
> Ok, so far I´ve received a lot of suggestions for my
> queston about gaming
> programing and I´ve resolved to begin with C++ (of
> wich I already know a
> lot) and second, I´ll use OpenGL (its no-microsoft
> nature won the battle)
> 
> Now, I´m having problems trying to capture the arrow
> keys from the keyboard
> and the Enter and Fx strokes. A long time ago I
> readed how to make this but
> in Pascal, so I need the code in C.  I already did
> this code:
> 
>  clrscr();
>  flushall();
>  c = getchar();
> 
> with c as integer and as char but it just return the
> number 10 when I press
> the Enter key and doesn´t works at all with the
> arrows. I know there is
> another numerical code I have to capture but I don´t
> get it right now.
> 
> Thanks for your help
> 
> 
> PS: BTW it would be nice if somebody have the code
> necesary to capture the
> Fx keys. Thanks again!
> 
> =================================================================
> To SUBSCRIBE or UNSUBSCRIBE please visit
> http://gameprogrammer.com/mailinglist.html
> 

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com
=================================================================
To SUBSCRIBE or UNSUBSCRIBE please visit
http://gameprogrammer.com/mailinglist.html