Fireballs
Now let’s use our new function by coding the fireballs. To get started with creating our fireballs, we need some new classes. Create two new classes, FireballUpdate
and FireballGraphics
, and derive them from Update
and Graphics
respectively.
Coding the FireballUpdate class
To begin the process of coding the FireballUpdate
class, in FireballUpdate.h
add the following code:
#pragma once
#include "Update.h"
#include <SFML/Graphics.hpp>
using namespace sf;
class FireballUpdate :
public Update
{
private:
FloatRect m_Position;
FloatRect* m_PlayerPosition;
bool* m_GameIsPaused = nullptr;
float m_Speed = 250;
float m_Range = 900;
int m_MaxSpawnDistanceFromPlayer = 250;
bool m_MovementPaused = true;
Clock m_PauseClock;
float m_PauseDurationTarget = 0;
float m_MaxPause = 6;
float m_MinPause = 1;
//float mTimePaused = 0;
bool m_LeftToRight = true;
public:
FireballUpdate(bool* pausedPointer...