Computer Science Canada

Moving procedure

Author:  Sauvus [ Fri May 04, 2012 1:48 pm ]
Post subject:  Moving procedure

I'm having trouble with my code. Whenever i do / (Which is the attack key in my game) does not work. all the variables that use the sprite pictures are already set up. but for some reason it just doesnt work. but it works for movement instead.
Quote:
procedure P1movement
var directionup := 1
var directiondown := 1
var directionleft := 1
var directionright := 1
var directionattack := 1

loop
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) then
y += 10
if directionup < 2 then
directionup += 1
else
directionup := 1

end if
end if
if chars (KEY_DOWN_ARROW) then
y -= 10
if directiondown < 2 then
directiondown += 1
else
directiondown := 1
end if
end if
if chars (KEY_LEFT_ARROW) then
x -= 10
if directionleft < 2 then
directionleft += 1
else
directionleft := 1
end if
end if

if chars (KEY_RIGHT_ARROW) then
x += 10
if directionright < 2 then
directionright += 1
else
directionright := 1
end if

if chars ('/') then
if directionattack < 2 then
directionattack += 1
else
directionattack := 1
end if
end if
end if


if directionattack = 1 then
Sprite.ChangePic (psprite1, Pic7)
elsif directionattack = 2 then
Sprite.ChangePic (psprite1, Pic8)
end if

if directionup = 1 then
Sprite.ChangePic (psprite1, Pic5)
elsif directionup = 2 then
Sprite.ChangePic (psprite1, Pic6)
end if

Sprite.SetPosition (psprite1, x, y, false)
Sprite.Show (psprite1)
delay (70)
end loop
end P1movement

Author:  Tony [ Fri May 04, 2012 3:08 pm ]
Post subject:  RE:Moving procedure

in what way does it not work? What did you try to do to investigate the problem?


: