The Locator class definition

The Locator class is a new class for a UI element that will be an arrow pointing our player in the direction of the enemy spaceship. We require a UI element to help the player find the enemy spaceship when it does not appear on the canvas. Here is what the class definition looks like:

class Locator {
public:
bool m_Active = false;
bool m_LastActive = false;
SDL_Texture *m_SpriteTexture;
SDL_Rect m_dest = {.x = 0, .y = 0, .w = 32, .h = 32 };
Vector2D m_Position;
int m_ColorFlux;
float m_Rotation;

Locator();
void SetActive();
void Move();
void Render();
};

The first two attributes are Boolean flags that have to do with the active state of the locator. The m_Active attribute tells us whether the locator is currently active and should be rendered. The m_LastActive attribute is a Boolean flag that tells us whether the locator was active the last time a frame was rendered. The next two lines are the sprite texture and the destination rectangle that will be used by the render manager to render this game object:

        SDL_Texture *m_SpriteTexture;
SDL_Rect m_dest = {.x = 0, .y = 0, .w = 32, .h = 32 };

After that, we have an x and y positional value in the m_Position attribute, an integer that represents an RGB color value in m_ColorFlux, and a rotation value for the sprite in the m_Rotation attribute. We will be using the m_ColorFlux attribute to cause the color of the arrow to be redder when the enemy is close, and whiter when the enemy is further away.

The last four lines of this class definition are the class functions. There is a constructor, a function that sets the status of the locator to active, and Move and Render functions:

        Locator();
void SetActive();
void Move();
void Render();