Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   arrow keys (https://forums.graalonline.com/forums/showthread.php?t=39411)

screen_name 10-18-2002 11:13 PM

arrow keys
 
Stefan, why don't you add keycodes for the arrow keys. Because the keydowns(0..3) just check for the specified key (so if they change it to j,k,l,o, then it will check those if i use keydown(0..3)

Com013 10-19-2002 12:05 AM

I doubt Stefan added the keycodes...they are those used by the BIOS/Windows. Just look in some table for the keycodes for the arrow keys.
Here, I found those in the header file of a DOS game programming library (Allegro):
NPC Code:

#define KEY_LEFT 82
#define KEY_RIGHT 83
#define KEY_UP 84
#define KEY_DOWN 85


I didn't test them though.

Com013 10-20-2002 04:09 AM

Ok, they were wrong. I needed to write a windows program to get the right ones. Here they are:
up - 38
left - 37
down - 40
right - 39
Graal isn't triggering a keypressed event though. You need to check it in timeouts.

R0bin 10-20-2002 06:56 AM

that isnt standard ASCII code though, so it wouldnt do anything with keydown2

Kaimetsu 10-20-2002 08:34 AM

I've had arrow keys work with keydown2 before.

R0bin 10-20-2002 09:44 AM

bah :P never worked for me

Com013 10-20-2002 07:53 PM

Quote:

Originally posted by R0bin
that isnt standard ASCII code though, so it wouldnt do anything with keydown2
Huh? Something like this worked for me:
NPC Code:

if (playerenters) {
timeout = 0.05;
}
if (timeout) {
if (keydown2(38,true)) message Up;
if (keydown2(37,true)) message Left;
if (keydown2(40,true)) message Down;
if (keydown2(39,true)) message Right;
timeout = 0.05;
}


CheeToS2 10-21-2002 12:18 AM

Quote:

Originally posted by Kaimetsu
I've had arrow keys work with keydown2 before.
along with keypressed, though?

Kaimetsu 10-21-2002 09:00 AM

Quote:

Originally posted by CheeToS2


along with keypressed, though?

Maybe. Maybe not. Does it matter?

CheeToS2 10-21-2002 05:31 PM

Quote:

Originally posted by Kaimetsu


Maybe. Maybe not. Does it matter?

yes, it does, since that is part of the point of this thread! (in regards to Com's post)

Loriel 10-21-2002 06:39 PM

Quote:

Originally posted by R0bin
that isnt standard ASCII code though, so it wouldnt do anything with keydown2
We are talking about keycodes here, which is keyboard input as far as I know. ASCII is something with fonts or whatever.

Kaimetsu 10-21-2002 09:38 PM

Quote:

Originally posted by CheeToS2


yes, it does, since that is part of the point of this thread! (in regards to Com's post)

But there's nothing you can do with keypressed that you can't do with keydown2 and a timeout loop.

Jeff 10-22-2002 12:13 AM

Kai:

That is true, however, as I understand it keypressed is far more efficient.

Kaimetsu 10-22-2002 06:25 AM

Quote:

Originally posted by Jeff
Kai:

That is true, however, as I understand it keypressed is far more efficient.

I'd hardly say 'far' more efficient. None of us really know how Graal's internal workings are organised. I could argue that the use of event flags like keypressed takes more cpu time because it requires Graal to search the flag list, for example, but either way the difference in efficiency is going to be negligible.

adam 10-26-2002 02:10 AM

Quote:

Originally posted by Kaimetsu


I'd hardly say 'far' more efficient. None of us really know how Graal's internal workings are organised. I could argue that the use of event flags like keypressed takes more cpu time because it requires Graal to search the flag list, for example, but either way the difference in efficiency is going to be negligible.

I think it totally depends on the situation...

If you already need to use a timeout loop for something else... just add the key checks to it...


If you don't have any timeouts... don't bother with one. Just use keypressed...


All times are GMT +2. The time now is 07:13 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.