
-----------------------------------
KONjbnj
Mon May 30, 2005 3:43 pm

Using arrow keys?How?
-----------------------------------
How do i for example use the arrow keys to move a dot on the screen. Im a noob so ......

-----------------------------------
StarGateSG-1
Mon May 30, 2005 4:03 pm


-----------------------------------
Use Input Ky Down look it up!

-----------------------------------
syphon4
Fri Jun 03, 2005 4:04 pm

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
Mon Jun 06, 2005 6:42 pm


-----------------------------------

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
Mon Jun 06, 2005 9:26 pm


-----------------------------------
And instead of

x2:=x2+2


you could put 

x2+=2


-----------------------------------
syphon4
Wed Jun 08, 2005 2:54 pm

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
Wed Jun 08, 2005 3:01 pm


-----------------------------------
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
Wed Jun 08, 2005 3:32 pm

Re: 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

his post was pretty necessary since its best to keep things short and simple.
