[REBOL] Re: kbhit()
From: jeff:rebol at: 22-Jun-2001 12:18
What are you trying to do, Holger?
One up me or something???
;-)
> Why not
>
> con: open/direct/binary/no-wait console://
> until [wait con]
> choice: to-char pick con 1
>
> No crazy poll loops needed :-).
Gahh.. huh?? Above's a busy loop, especially with no-wait, eh?
Above loops away waiting for a single char.
to-char first wait open/direct/binary console://
Above waits (no loop) for a single char and returns it.
Presumably someone wants kbhit because they want to make a
spaceship game, so you *want* to poll.
REBOL [
Title: "Spaceship game framework"
]
conn: open/direct/binary/no-wait console://
;-- returns false otherwise
do input?-val: has [c][if c: wait conn [to-char first c]]
forever [
if c: input?-val [
switch/default c [
#"z" [fire-missile]
#"q" [quit]
#"s" [toggle-sound]
...
][default-case]
]
make-other-ships-move-and-stuff
wait .02
]