Getch input
Author |
Message |
Walker
|
Posted: Sat Jun 05, 2004 8:24 pm Post subject: Getch input |
|
|
okay im using a keyboard for input and my code is
code: |
if hasch then
getch (key)
end if
if key = ("w") then
yy := yy + 20
elsif chars ("s") then
yy := yy - 20
elsif chars ("d") then
xx := xx + 20
elsif chars ("a") then
xx := xx - 20
|
i would ecpect this to move the xx and yy values up and down by using the w,s,a and d keys but instead is does nothing. What did i do wrong? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Delos
![](http://www.members.shaw.ca/rfolz/delos_avatar.gif)
|
Posted: Sat Jun 05, 2004 8:30 pm Post subject: (No subject) |
|
|
How about you get rid of the if hasch part. It seems redundant to me.
code: |
loop
getch (key)
if key = "w" then
%...
end if
end loop
|
I'm not entirely sure what your "+ 20" thing was all about...I can only imagine that it has something to do with your locates? Well, that is if you are using ASCII art.
Otherwise, it probably has something to do with your xy-coords? I'm just guessing... |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Sun Jun 06, 2004 7:38 am Post subject: (No subject) |
|
|
you switch from asking "is key = to whatever character" to "is chars = to whatever character".
if you are using this for a game, read up on Input.KeyDown() |
|
|
|
|
![](images/spacer.gif) |
AsianSensation
|
Posted: Sun Jun 06, 2004 6:13 pm Post subject: (No subject) |
|
|
code: | var key : string (1)
var x, y : int := 0
loop
if hasch then
getch (key)
if key = ("w") then
y += 10
elsif key = ("s") then
y -= 10
elsif key = ("d") then
x += 10
elsif key = ("a") then
x -= 10
end if
end if
drawfillbox (x, y, x + 10, y + 10, black)
end loop |
|
|
|
|
|
![](images/spacer.gif) |
|
|