Computer Science Canada Diagonal Movement |
Author: | bluedevils_77 [ Fri Apr 21, 2006 5:01 pm ] |
Post subject: | Diagonal Movement |
My code: var chars :array char of boolean var x,y,x1,y1: int x1 := 100%variables duh y1:= 190 x:= 100 y:= 100 loop Input.KeyDown(chars) %drawing it Draw.Line (x,y,x1,y1,7) delay(10) cls %it going up if chars (KEY_UP_ARROW) then y:=y +2 y1:= y1 +2 %it gonig down elsif chars (KEY_DOWN_ARROW) then y:=y-2 y1:= y1 - 2 %left elsif chars (KEY_LEFT_ARROW) then x:=x - 2 x1:= x1 - 2 %right elsif chars (KEY_RIGHT_ARROW) then x:= x + 2 x1:= x1 + 2 %TEYING TO GET TO GO DIAGONAL UP AND TO THE LEFT.. IUNNO HOW, AND THIS ISNT WORKING elsif chars (KEY_UP_ARROW) and chars (KEY_LEFT_ARROW) then x:=x-2 y:=y +2 end if end loop im tryin to get this simple line to get ^ and to the <-- at the same time, but when i press both the up and left button it either goes up or left?? |
Author: | TokenHerbz [ Fri Apr 21, 2006 5:22 pm ] | ||
Post subject: | |||
its because in your IF statement, if you press one key it will only acknowledge the true statemnet one at a time. What you need to do is make it inyo 2 if statments like so...
|