Computer Science Canada

Movement problem

Author:  Barda4 [ Tue Feb 20, 2007 4:29 pm ]
Post subject:  Movement problem

Ok I am having trouble getting my guy to move. I have it in the processes that he is supposed to move but he doesn't. What happens is he actually get onto the screen but he doesn't move. I believe that turing isn't reading the key input plz help me i need it I am way over my head with this. Here the code

var chars : array char of boolean
loop
Input.KeyDown (chars)
end loop
if chars (KEY_RIGHT_ARROW) then
fork linkwalkright
chright := true
chleft := false
chup := false
chdown := false
elsif chars (KEY_LEFT_ARROW) then
fork linkwalkleft
chleft := true
chright := false
chup := false
chdown := false
elsif chars (KEY_UP_ARROW) then
fork linkwalkup
chup := true
chright := false
chleft := false
chdown := false
elsif chars (KEY_DOWN_ARROW) then
fork linkwalkdown
chdown := true
chright := false
chleft := false
chup := false
end if

Author:  CodeMonkey2000 [ Tue Feb 20, 2007 10:40 pm ]
Post subject:  Re: Movement problem

Put the end loop at the end of your code. Like so:
Turing:
var chars : array char of boolean
loop
    Input.KeyDown (chars)
    if chars (KEY_RIGHT_ARROW) then
        fork linkwalkright
        chright := true
        chleft := false
        chup := false
        chdown := false
    elsif chars (KEY_LEFT_ARROW) then
        fork linkwalkleft
        chleft := true
        chright := false
        chup := false
        chdown := false
    elsif chars (KEY_UP_ARROW) then
        fork linkwalkup
        chup := true
        chright := false
        chleft := false
        chdown := false
    elsif chars (KEY_DOWN_ARROW) then
        fork linkwalkdown
        chdown := true
        chright := false
        chleft := false
        chup := false
    end if
end loop

Didn't you already ask this?

Author:  BenLi [ Tue Feb 20, 2007 11:23 pm ]
Post subject:  RE:Movement problem

and just a note i think you'd have a much easier time seeing a simple problem like that if you indent your code, and its turing so just press F2


: