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

Username:   Password: 
 RegisterRegister   
 How to change picture according to player movement?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jky09




PostPosted: 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>

Turing:


<Add your code here>



Please specify what version of Turing you are using
4.1.1



BOMBERMAN_CPT HANDIN.7z
 Description:
Not a finished game, so the gameplay is not finished. And our menu is kinda messed :/

Download
 Filename:  BOMBERMAN_CPT HANDIN.7z
 Filesize:  2.26 MB
 Downloaded:  47 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Insectoid




PostPosted: 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.
jky09




PostPosted: 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?
Tony




PostPosted: 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.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: