keyboard input help
Author |
Message |
TokenHerbz
![](http://compsci.ca/v3/uploads/user_avatars/717170395558e628d9452b.jpg)
|
Posted: Sat Jul 23, 2005 2:43 am Post subject: keyboard input help |
|
|
i seen this in the help files
code: |
Input.KeyDown (ball)
if ball (KEY_UP_ARROW) then
y:=y+speed
end if
if ball (KEY_RIGHT_ARROW) then
x:=x+speed
end if
if ball (KEY_LEFT_ARROW) then
x:=x-speed
end if
if ball (KEY_DOWN_ARROW) then
y:=y-speed
end if
|
But, i tryed KEY_SPACEBAR / KEY_BAR / KEY_SPACE / KEY_SPACE_BAR and well....
Can u post what i have to type to get the unput of all the keys on the keyboard...
Also, how do you rig up a press any key to continuue?
Thanks |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
jamonathin
![](http://compsci.ca/v3/uploads/user_avatars/57683465145f851a43dd9a.gif)
|
Posted: Sat Jul 23, 2005 7:35 am Post subject: (No subject) |
|
|
Well, what happens is, (KEY_WHATEVER) only works for 'keys' that dont make a character. such as (KEY_LEFT_ARROW) , (KEY_PGDN), (KEY_ENTER). Anything else all you do is type ('key') where key is whatever button you pressed. So space bar is (' ') and q is ('q') |
|
|
|
|
![](images/spacer.gif) |
Delos
![](http://www.members.shaw.ca/rfolz/delos_avatar.gif)
|
Posted: Sat Jul 23, 2005 10:47 am Post subject: (No subject) |
|
|
F10 wrote:
Here is a list of most of the constants
KEY_F1 .. KEY_F12 KEY_CTRL_A .. KEY_CTRL_Z
KEY_SHIFT_F1 .. KEY_SHIFT_F12 KEY_ALT_A .. KEY_ALT_Z
KEY_CTRL_F1 .. KEY_CTRL_F12 KEY_ALT_1 .. KEY_ALT_0
KEY_ALT_F1 .. KEY_ALT_F12
KEY_HOME KEY_CTRL_HOME
KEY_UP_ARROW KEY_CTRL_UP_ARROW
KEY_PGUP KEY_CTRL_PGUP
KEY_LEFT_ARROW KEY_CTRL_LEFT_ARROW
KEY_RIGHT_ARROW KEY_CTRL_RIGHT_ARROW
KEY_END KEY_CTRL_END
KEY_DOWN_ARROW KEY_CTRL_DOWN_ARROW
KEY_PGDN KEY_CTRL_PGDN
KEY_INSERT KEY_CTRL_INSERT
KEY_DELETE KEY_CTRL_DELETE
KEY_BACKSPACE KEY_KEYPAD_5 *
KEY_TAB KEY_SHIFT *
KEY_ENTER KEY_CTRL *
KEY_ESC KEY_ALT *
KEY_CTRL_OPEN_BRACKET KEY_CTRL_BACKSLASH
KEY_CTRL_CLOSE_BRACKET KEY_CTRL_CARET
KEY_CTRL_UNDERSCORE KEY_CTRL_BACKSPACE
KEY_ALT_MINUS KEY_ALT_EQUALS
KEY_BACK_TAB KEY_SHIFT_TAB
Above constants with "ORD_" instead of "KEY_"
ORD_A .. ORD_Z ORD_0 .. ORD_9
ORD_LOWER_A .. ORD_LOWER_Z
ORD_SPACE ORD_EXCALAMATION_MARK
ORD_QUOTATION_MARK ORD_HAS_MARK
ORD_DOLLAR_SIGN ORD_PERCENT_SIGN
ORD_AMPERSAND ORD_SINGLE_QUOTE
ORD_OPEN_PARENTHESIS ORD_CLOSE_PARENTHESIS
ORD_ASTERISK ORD_PLUS
ORD_COMMA ORD_MINUS
ORD_PERIOD ORD_DOT
ORD_SLASH ORD_COLON
ORD_SEMICOLON ORD_LESS_THAN
ORD_EQUALS ORD_GREATER_THAN
ORD_QUESTION_MARK ORD_AT_SIGN
ORD_OPEN_BRACKET ORD_BACKSLASH
ORD_CLOSE_BRACKET ORD_CARET
ORD_UNDERSCORE ORD_APOSTROPHE
ORD_OPEN_BRACE ORD_BAR
ORD_CLOSE_BRACE ORD_TILDE
As jamonathin said, you can just use (' ') for space. As for 'any key', you could just use an Input.Pause, which would give you your desired effect. |
|
|
|
|
![](images/spacer.gif) |
TokenHerbz
![](http://compsci.ca/v3/uploads/user_avatars/717170395558e628d9452b.jpg)
|
Posted: Sat Jul 23, 2005 12:25 pm Post subject: (No subject) |
|
|
ok thank you....
If anywant wants to test it now!
code: |
var x, y: int
var ball : array char of boolean
var c: int
var speed: int := 1
randint (x,10,500)
randint (y,10,300)
put "Move ball with arrow keys."
put "Spacebar moves ball faster."
put "Shift to unstick your ball."
Input.Pause
%Moves ball
loop
randint (c,1,99)
Input.KeyDown (ball)
if ball (KEY_UP_ARROW) then
y:=y+speed
end if
if ball (KEY_RIGHT_ARROW) then
x:=x+speed
end if
if ball (KEY_LEFT_ARROW) then
x:=x-speed
end if
if ball (KEY_DOWN_ARROW) then
y:=y-speed
end if
if x >= maxx - 5 then
x *= -1
elsif x <= 5 then
x *= -1
elsif y >= maxy - 5 then
y *= -1
elsif y <= 5 then
y *= -1
end if
if ball (' ') then
speed := 5
else
speed := 1
end if
if ball (KEY_SHIFT) then
randint (x,10,500)
randint (y,10,300)
end if
%draws ball
drawfilloval(x,y,5,5,c)
delay(10)
cls
end loop
|
Anyways, please look over in my bouncing balls forum, i still need help there. |
|
|
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Sat Jul 23, 2005 4:16 pm Post subject: (No subject) |
|
|
Delos wrote: you could just use an Input.Pause, which would give you your desired effect.
actually i dont think so, if he wants to use it in a loop that will perform a function of an Input.Keydown key. i think
will be a way to go. |
|
|
|
|
![](images/spacer.gif) |
jamonathin
![](http://compsci.ca/v3/uploads/user_avatars/57683465145f851a43dd9a.gif)
|
Posted: Sat Jul 23, 2005 4:29 pm Post subject: (No subject) |
|
|
MysticVegeta wrote:
he probabily doesn't know how to uset hat properly. Basically, if all you want is a "Press any key to continue" then
code: |
put "Press any key to continue"
loop
exit when hasch
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
Delos
![](http://www.members.shaw.ca/rfolz/delos_avatar.gif)
|
Posted: Sat Jul 23, 2005 6:00 pm Post subject: (No subject) |
|
|
I must express my confusion as to why Input.Pause would be an adverse function to use here.
This works quite nicely in any loop or other such place. Notice that Input.Flush that removes any buffered input, quite handy I might add. |
|
|
|
|
![](images/spacer.gif) |
jamonathin
![](http://compsci.ca/v3/uploads/user_avatars/57683465145f851a43dd9a.gif)
|
Posted: Sat Jul 23, 2005 8:12 pm Post subject: (No subject) |
|
|
The only thing that I dont like about it is that it kinda takes away from programming. I could probabily explain this a little better but, what i mean is I personally would rather make a command, then use someone else's, especially when it's as basic as that. Because you could just stick that loop in a proc and call it 'Jamonathin.Pause'. I just try to stay away from using commands that I could do myself.
Some things like drawfillcircle can be done with drawfillarc - doesn't really matter tho. And i guess you could use drawdot for drawline. There's a bunch of others that i just skip over and do myself, so I can understand the command and apply it the "technique" to other languages that I'm new to.
But yeah, that's just me though. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Mon Jul 25, 2005 8:21 pm Post subject: (No subject) |
|
|
jamonathin wrote:
The only thing that I dont like about it is that it kinda takes away from programming. I could probabily explain this a little better but, what i mean is I personally would rather make a command, then use someone else's, especially when it's as basic as that.
Man, this is the second time I've quoted this. Thanks wtd!
wtd wrote:
Don't reinvent the wheel if there's an existing library function to do it for you
Comon jamonathin: good programmers are lazy. ![Wink Wink](http://compsci.ca/v3/images/smiles/icon_wink.gif) |
|
|
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Mon Jul 25, 2005 8:26 pm Post subject: (No subject) |
|
|
Why remake something that already exists, when you can make something new with what does exist? Unless, of course you are remaking something better than the original. It's much more appreciated . |
|
|
|
|
![](images/spacer.gif) |
jamonathin
![](http://compsci.ca/v3/uploads/user_avatars/57683465145f851a43dd9a.gif)
|
Posted: Tue Jul 26, 2005 12:12 am Post subject: (No subject) |
|
|
I don't know about other people, but just the way I am, I'll look at something on the computer, or sometimes in real life, I'll think of how it would of been programmed. Then I wonder how life was created. Then think: Is God a 1337 H@X0R? i dunno man. just how i am at times. ![Neutral Neutral](http://compsci.ca/v3/images/smiles/icon_neutral.gif) |
|
|
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Tue Jul 26, 2005 6:03 pm Post subject: (No subject) |
|
|
wow pausing commands occupy the topic for 11 replies! |
|
|
|
|
![](images/spacer.gif) |
jamonathin
![](http://compsci.ca/v3/uploads/user_avatars/57683465145f851a43dd9a.gif)
|
Posted: Wed Jul 27, 2005 12:59 pm Post subject: (No subject) |
|
|
MysticVegeta wrote: wow pausing commands occupy the topic for 11 replies! Well that's what a difference of opinions will do ![Razz Razz](http://compsci.ca/v3/images/smiles/icon_razz.gif) |
|
|
|
|
![](images/spacer.gif) |
|
|