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

Username:   Password: 
 RegisterRegister   
 Finding a new X,Y after rotating the image inside turing?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Atherial




PostPosted: Tue Dec 08, 2015 10:08 am   Post subject: Finding a new X,Y after rotating the image inside turing?

Okay. This is not going to be in depth as I have attempted to post it five or so times, only to have it deleted each time.

I am attempting to turn my sprite when it reaches a hill. Of course, I am able to rotate the sprite, but I cant find new X's and Y's after its rotated.
I tried making a whatdotcolor at the bottom right corner of the tank so that when it goes into the hill, it turns until it is no longer in the hill, but I cant find the new X,Y after I rotate it

IE.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Posted Image, might have been reduced in size. Click Image to view fullscreen.

How do I make it rotate to the same angle as the hill?

Code attached, W and S to raise and lower tank barrel, A and D to move.



TANK.zip
 Description:
Tank game, help guide me in the right direction please :)

Download
 Filename:  TANK.zip
 Filesize:  2.39 KB
 Downloaded:  94 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Tue Dec 08, 2015 2:55 pm   Post subject: RE:Finding a new X,Y after rotating the image inside turing?

This is where the trigonometry you learned (or will learn) in math class actually gets used. You need to know the rotation point of the sprite. This is probably the centre of it. Imagine a line from that point to the (x, y) you labeled in your picture. That line is the hypotenuse of a right triangle. You can now find the length and angle of that line just like in math class. When you rotate it with Pic.Rotate or Sprite.Rotate, you tell the function how many degrees to rotate by. Add those degrees to your original angle. You now have a new angle and the length of the line, which forms a new right triangle. From there, use soh cah toa to find the new coordinates.

It's a long process but just do it one step at a time. It might help to solve the problem once on paper, to figure out all the math.
Atherial




PostPosted: Wed Dec 09, 2015 11:39 am   Post subject: Re: Finding a new X,Y after rotating the image inside turing?

Thanks for the reply!

My math is next semester and unfortunately that means I do not understand soa sin cos, etc.
If someone has an equation, I may be able to fill it in that way?
Thanks
-Mac
Insectoid




PostPosted: Wed Dec 09, 2015 6:53 pm   Post subject: RE:Finding a new X,Y after rotating the image inside turing?

Have a look through Google for a soh cah toa tutorial. It's not terribly difficult. I'm pretty sure that's all you need to know for this problem.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: