Computer Science Canada Using arrow keys?How? |
Author: | KONjbnj [ 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 ...... |
Author: | StarGateSG-1 [ Mon May 30, 2005 4:03 pm ] |
Post subject: | |
Use Input Ky Down look it up! |
Author: | syphon4 [ 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 |
Author: | syphon4 [ Mon Jun 06, 2005 6:42 pm ] | ||
Post subject: | |||
make an object you want to move |
Author: | lyam_kaskade [ Mon Jun 06, 2005 9:26 pm ] | ||||
Post subject: | |||||
And instead of
you could put
|
Author: | syphon4 [ 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 |
Author: | lyam_kaskade [ Wed Jun 08, 2005 3:01 pm ] |
Post 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. |
Author: | vagyb [ 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. |