Let me start with a simple explanation of my collision system. Every object in my game is just a sprite with a defined vertexes. For example a triangle block is made of 3 vertexes. The collision between a ball (that is my player) and the triangle is done by calculating shortest distance between every edge of the triangle, and every edge is made of 2 vertexes. I am sure you know what I mean.
Until now everything was fine, but now I want to rotate some of the objects. And here comes the problem: when rotating the sprite, how to calculate new positions for for the vertexes.
Picture as an example. Red dots are the vertexes for calculating collision. Blue dot represents anchor, around which the sprite rotates (so the sprite rotates around its center). (1) is the object without any rotation. After the rotation i want to move the vertexes so they fit the actual display (2), and not stay as they stood before (3). I would appreciate any help
I was messing around with a piece of paper and probably found a solution. Every vertex <-> center distance is const. Assuming that I increase angle by 5 degrees i can use basic trigonometry (sinus and cosinus) to calculate new X and Y for every vertex.
Correct me if I am wrong. Also I don't know how calculating sin/cos every frame would consume the processing power. I am afraid it would be pretty devastating for the processor (creating a mobile game). Another idea is to keep x/y offsets for every vertex, for every degree, for every type of object. Like a mini-database. But... duh.. i hope there is a better solution..