Arrow Keys+scan code= !@$%
Gander at this first:
#define RtArrw 0x4d
#define LftArrw 0x4b
#define UpArrw 0x48
#define DnArrw 0x50
...
//Movement
switch(getch()){
case LftArrw:{...}
case UpArrw:{...}
case RtArrw:{...}
case DnArrw:{...}
};
Now when I do this, the arrow keys dont work, but I J L & M do.
I''d really really really like to know whats going on, and how to get them to work for my RPG.
With an arrow key there will be two getch''s sent. The first will be a zero and then the keycode. For example:
[Resist Windows XP''s Invasive Production Activation Technology!]
switch(getch()) { case 0: switch(getch()) { case LEFT: // ... break; // ... } break;}
[Resist Windows XP''s Invasive Production Activation Technology!]
I remember learning this in Pascal at college!
Like the above post says you have to read the keypress twice because arrow key, function key etc use extended scan code...the first code will just be a zero so you have to call getch() straight after the first one to actually get the scan code.
In Pascal (like you ever wanted to know!) it''s:
var ch : char;
begin
ch:=readkey;
ch:=readkey;
case ch of...
...
end;
end;
I just felt like putting that in!
Steve
---------------------
Light of my life
Fire of my loins.
My sin, my soul
LOLITA
---------------------
Like the above post says you have to read the keypress twice because arrow key, function key etc use extended scan code...the first code will just be a zero so you have to call getch() straight after the first one to actually get the scan code.
In Pascal (like you ever wanted to know!) it''s:
var ch : char;
begin
ch:=readkey;
ch:=readkey;
case ch of...
...
end;
end;
I just felt like putting that in!
Steve
---------------------
Light of my life
Fire of my loins.
My sin, my soul
LOLITA
---------------------
Why do you keep starting new threads for the same question continued (this is your third I believe)? It''s rude.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement