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

Username:   Password: 
 RegisterRegister   
 Rotating a Sprite.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Qwertyuiop K




PostPosted: Thu Jan 03, 2013 10:02 pm   Post subject: Rotating a Sprite.

What is it you are trying to achieve?
Rotate a sprite based on mouse position. I have a cannon, and if you click, it shoots at the location. However, I want the cannon to follow the mouse.


What is the problem you are having?
Don't know how to do it.


Describe what you have tried to solve this problem
Turing manual.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
N/A; have no code for it at the moment.

Turing:


N/A



Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
jr5000pwp




PostPosted: Thu Jan 03, 2013 10:10 pm   Post subject: RE:Rotating a Sprite.

http://compsci.ca/holtsoft/doc/pic_rotate.html

You should be able to rotate it with that, since you have it firing in a certain direction you already have the angle, you might need to convert it though. If you only have one cannon you should be able to rotate it every frame without completely killing performance, but I would consider storing a couple of possible rotations (One every 5/10/15 degrees)
Qwertyuiop K




PostPosted: Thu Jan 03, 2013 10:25 pm   Post subject: RE:Rotating a Sprite.

For firing, I used slope rather than angle. Since the cannon to the point of fire is linear, that's what I thought of first.

As for Pic.Rotate, I tried but it didn't work well.
Insectoid




PostPosted: Thu Jan 03, 2013 10:47 pm   Post subject: RE:Rotating a Sprite.

You'll probably want to use Pic.Rotate to generate 180 images at the beginning of your program. It will lag a lot if you do it during the game. Turing has a small limit (around 1000 I think) on the number of images you can load at once, so you probably won't want the full 360 images and you won't be able to tell the difference anyway. Store them all in an array and call them as necessary. With Sprite.Animate() you can change the image, and if you already know what angle the cannon is pointing, you just use that angle as the array index for your image.
Qwertyuiop K




PostPosted: Fri Jan 04, 2013 1:50 am   Post subject: RE:Rotating a Sprite.

Thanks, finally got it to work! Smile However, instead of Sprite.Animate, I used Sprite.ChangePic.
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: