Computer Science Canada How to change picture according to player movement? |
Author: | jky09 [ Wed Jan 09, 2013 6:23 pm ] | ||
Post subject: | How to change picture according to player movement? | ||
What is it you are trying to achieve? My goal is to try to change pictures of a player according to the movement (up,down,left,right) I know this isn't the usual way to accomplish rotation in games, but the only rotation code that I know is Pic.Rotate, which won't work. What is the problem you are having? I'm not sure of the coding/way to accomplish it Describe what you have tried to solve this problem I tried (basically): Input.KeyDown (chars) if chars (KEY_UP_ARROW) and tiles (px, py+1) = 0 then py +=1 put playerpicture (variable stated above in the coding) end if (Full Code Below) Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <Answer Here>
Please specify what version of Turing you are using 4.1.1 |
Author: | Tony [ Wed Jan 09, 2013 6:36 pm ] |
Post subject: | RE:How to change picture according to player movement? |
Maybe if you had 4 different pictures, and keep track of which way the player is facing in a variable? You can then use that variable to decide which of the pictures to use. |
Author: | Insectoid [ Wed Jan 09, 2013 6:37 pm ] |
Post subject: | RE:How to change picture according to player movement? |
The easiest way to do this is to use 4 pictures instead- one in each direction. Load them all up into separate variables in the beginning of your program. Then if the 'up' key is pressed, draw the 'up' image. Likewise for all other directions. |
Author: | jky09 [ Thu Jan 10, 2013 10:18 am ] |
Post subject: | Re: How to change picture according to player movement? |
How would I make the new picture (according to direction) replace the previous picture? My thought was that I could put: var charA :=Pic.FileNew ("FileName") var chardirection :=Pic.FilewNew ("filename") If chars (KEY_UP_ARROW) and tiles (px, py + 1) = 0 then py += 1 charA := chardirection end if obviously this doesn't work, any ideas? |
Author: | Tony [ Thu Jan 10, 2013 4:22 pm ] |
Post subject: | RE:How to change picture according to player movement? |
it's not obvious why this doesn't work. |