Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Moving procedure
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Sauvus




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: