Author |
Message |
KONjbnj
|
Posted: Mon May 30, 2005 3:43 pm Post subject: Using arrow keys?How? |
|
|
How do i for example use the arrow keys to move a dot on the screen. Im a noob so ...... |
|
|
|
|
|
Sponsor Sponsor
|
|
|
StarGateSG-1
|
Posted: Mon May 30, 2005 4:03 pm Post subject: (No subject) |
|
|
Use Input Ky Down look it up! |
|
|
|
|
|
syphon4
|
Posted: Fri Jun 03, 2005 4:04 pm Post subject: move |
|
|
here is a simple program to move a crosshair i created...........learn from it
View.Set ("graphics:640;480,offscreenonly")
var horizontal, vertical : int := 25
var keyinput : string (1) := "x"
loop
Draw.Line (horizontal + 15, vertical, horizontal - 15, vertical, 2)
Draw.Line (horizontal, vertical + 15, horizontal, vertical - 15, 2)
locate (1, 1)
if hasch then
getch (keyinput)
end if
if keyinput = chr (119) then %up arrow
vertical += 5
keyinput := "x"
elsif keyinput = chr (100) then %right arrow
horizontal += 5
keyinput := "x"
elsif keyinput = chr (97) then %left arrow
horizontal -= 5
keyinput := "x"
elsif keyinput = chr (115) then %down arrow
vertical -= 5
keyinput := "x"
end if
View.Update
cls
exit when keyinput = chr (10)
end loop |
|
|
|
|
|
syphon4
|
Posted: Mon Jun 06, 2005 6:42 pm Post subject: (No subject) |
|
|
code: |
var input : array char of boolean
Input.KeyDown (input)
if input (KEY_UP_ARROW) then % up
y2 := y2 + 2
elsif input (KEY_RIGHT_ARROW) then % right
x2 := x2 + 2
elsif input (KEY_LEFT_ARROW) then % left
x2 := x2 - 2
elsif input (KEY_DOWN_ARROW) then % down
y2 := y2 - 2
end if |
make an object you want to move |
|
|
|
|
|
lyam_kaskade
|
Posted: Mon Jun 06, 2005 9:26 pm Post subject: (No subject) |
|
|
And instead of
you could put
|
|
|
|
|
|
syphon4
|
Posted: Wed Jun 08, 2005 2:54 pm Post subject: turing |
|
|
was that post really necessary your way is exactly the same as mine tell me does it make your program more efficiant if......
x2:=x2+1 or x2+=1
NO it doesnt |
|
|
|
|
|
lyam_kaskade
|
Posted: Wed Jun 08, 2005 3:01 pm Post subject: (No subject) |
|
|
If my post wasn't necessary, then you're response was even less necessary.
Anyway, yes it's important to use proper format when coding, it makes your code less cluttered and easier to read.
EDIT:
Also, since assigning a new value to a variable based on it's original value is something very common in programming, augmented assignment operators allow you to type code that much faster. |
|
|
|
|
|
vagyb
|
Posted: Wed Jun 08, 2005 3:32 pm Post subject: Re: turing |
|
|
syphon4 wrote: was that post really necessary your way is exactly the same as mine tell me does it make your program more efficiant if......
x2:=x2+1 or x2+=1
NO it doesnt
his post was pretty necessary since its best to keep things short and simple. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|