Hello guys,
I am trying to rotate a sprite around a specific point on the screen. I managed to do so and here is what I have so far:
My Enemy update function:
void Enemy::update()
{
moveInCircle(&position, 1, 100, 100, 100);
{
My function to move sprite around point:
void moveInCircle(Vector2D* enemyPos, float speed, int centerX, int centerY, int radius)
{
float speedScale = (0.001 * 2 * PI) / speed;
float angle = SDL_GetTicks() * speedScale;
enemyPos->SetX(centerX + sin(angle) * radius);
enemyPos->SetY(centerY + cos(angle) * radius);
}
However, I want to be able to rotate the sprite in a limited angle, instead of just moving ad infinitum and here is where I got stuck, how can I check how many degrees the sprite have moved? Maybe there is a better approach on the function 'moveInCircle' than the one I used?
Thanks in advance,
lvenonl