Skip to content

Commit

Permalink
Changed Particles, made it Global.
Browse files Browse the repository at this point in the history
  • Loading branch information
LanceJZ committed Nov 25, 2024
1 parent 114b896 commit b002a46
Show file tree
Hide file tree
Showing 27 changed files with 13 additions and 103 deletions.
7 changes: 1 addition & 6 deletions Asteroids Reimagined/Enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ void Enemy::SetExplodeSound(Sound explodeSound)
ExplodeSound = explodeSound;
}

void Enemy::SetParticleManager(ParticleManager* particleManager)
{
Particles = particleManager;
}

bool Enemy::Initialize(Utilities* utilities)
{
LineModel::Initialize(utilities);
Expand Down Expand Up @@ -172,7 +167,7 @@ void Enemy::Hit()

if (!Player->GameOver) PlaySound(ExplodeSound);

if (Particles != nullptr) Particles->SpawnLineParticles(Position,
Particles.SpawnLineParticles(Position,
Vector3Multiply(Velocity, {0.25f}),
20, 100, 20, 2.0f, WHITE);

Expand Down
3 changes: 0 additions & 3 deletions Asteroids Reimagined/Enemy.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "Globals.h"
#include "ThePlayer.h"
#include "Shot.h"
#include "ParticleManager.h"

class Enemy : public LineModel
{
Expand All @@ -20,7 +19,6 @@ class Enemy : public LineModel
std::vector<Enemy*> Enemy2Refs;

void SetPlayer(ThePlayer* player);
void SetParticleManager(ParticleManager* particleManager);

void SetShotModel(LineModelPoints model);

Expand Down Expand Up @@ -64,7 +62,6 @@ class Enemy : public LineModel
Vector3 Destination = { 0.0f, 0.0f, 0.0f };

ThePlayer* Player = nullptr;
ParticleManager* Particles = nullptr;
Sound FireSound = {};
Sound ExplodeSound = {};
Sound OnSound = {};
Expand Down
1 change: 0 additions & 1 deletion Asteroids Reimagined/Enemy1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ void Enemy1::FireMissile() //TODO: Move common parts to Enemy class.
Missiles.push_back(DBG_NEW TheMissile());
Managers.EM.AddLineModel(Missiles.back(), MissileModel);
Missiles.back()->SetPlayer(Player);
Missiles.back()->SetParticleManager(Particles);
Missiles.back()->SetOnSound(MissileOnSound);
Missiles.back()->SetExplodeSound(MissileExplodeSound);
Missiles.back()->BeginRun();
Expand Down
1 change: 0 additions & 1 deletion Asteroids Reimagined/Enemy2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ void Enemy2::DropMine()
Managers.EM.AddLineModel(Mines.back(), MineModel);
Mines.back()->SetPlayer(Player);
Mines.back()->SetExplodeSound(MineExplodeSound);
Mines.back()->SetParticleManager(Particles);
Mines.back()->BeginRun();
}

Expand Down
13 changes: 1 addition & 12 deletions Asteroids Reimagined/EnemyControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,6 @@ void EnemyControl::SetBossSpineFireSound(Sound sound)
Boss->SetSpineFireSound(sound);
}

void EnemyControl::SetParticleManager(ParticleManager* particles)
{
Particles = particles;

DeathStar->SetParticleManager(particles);
Boss->SetParticleManager(particles);
}

bool EnemyControl::Initialize(Utilities* utilities)
{
Common::Initialize(TheUtilities);
Expand Down Expand Up @@ -518,7 +510,6 @@ void EnemyControl::SpawnUFO()
UFOs.back()->SetBigSound(UFOBigSound);
UFOs.back()->SetSmallSound(UFOSmallSound);
UFOs.back()->SetPlayer(Player);
UFOs.back()->SetParticleManager(Particles);
UFOs.back()->BeginRun();

for (const auto& enemy : EnemyOnes)
Expand Down Expand Up @@ -579,7 +570,6 @@ void EnemyControl::SpawnEnemyOne()
EnemyOnes.back()->SetOnSound(EnemyOneOnSound);
EnemyOnes.back()->SetMissileOnSound(EnemyOneMissileOnSound);
EnemyOnes.back()->SetPlayer(Player);
EnemyOnes.back()->SetParticleManager(Particles);
EnemyOnes.back()->BeginRun();
}

Expand Down Expand Up @@ -638,7 +628,6 @@ void EnemyControl::SpawnEnemyTwo()
EnemyTwos.back()->SetExplodeSound(EnemyTwoExplodeSound);
EnemyTwos.back()->SetOnSound(EnemyTwoOnSound);
EnemyTwos.back()->SetPlayer(Player);
EnemyTwos.back()->SetParticleManager(Particles);
EnemyTwos.back()->BeginRun();
}

Expand Down Expand Up @@ -824,7 +813,7 @@ void EnemyControl::CheckRockCollisions()

Rocks.at(i)->Destroy();
Managers.EM.ResetTimer(DeathStarSpawnTimerID);
Particles->SpawnLineParticles(Rocks.at(i)->Position,
Particles.SpawnLineParticles(Rocks.at(i)->Position,
Vector3Multiply(Rocks.at(i)->Velocity, { 0.25f, 0.25f }),
Rocks.at(i)->Radius * 0.25f, 15.0f, 15, 1.5f, WHITE);

Expand Down
4 changes: 0 additions & 4 deletions Asteroids Reimagined/EnemyControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "Enemy1.h"
#include "Enemy2.h"
#include "TheBoss.h"
#include "ParticleManager.h"

class EnemyControl : public Common
{
Expand Down Expand Up @@ -71,8 +70,6 @@ class EnemyControl : public Common
void SetBossTurretExplodeSound(Sound sound);
void SetBossSpineFireSound(Sound sound);

void SetParticleManager(ParticleManager* particles);

bool Initialize(Utilities* utilities);
bool BeginRun();

Expand Down Expand Up @@ -132,7 +129,6 @@ class EnemyControl : public Common
LineModelPoints MineModel;

ThePlayer *Player = nullptr;
ParticleManager *Particles = nullptr;

void SpawnRocks(Vector3 position, int count, TheRock::RockSize size);
void SpawnUFO();
Expand Down
5 changes: 0 additions & 5 deletions Asteroids Reimagined/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Game::Game()
//BackGroundID = Managers.EM.AddCommon(BackGround = DBG_NEW TheBackground());
EnemiesID = Managers.EM.AddCommon(Enemies = DBG_NEW EnemyControl());
PlayerID = Managers.EM.AddLineModel(Player = DBG_NEW ThePlayer());
ParticlesID = Managers.EM.AddCommon(Particles = DBG_NEW ParticleManager());
}

Game::~Game()
Expand All @@ -23,7 +22,6 @@ bool Game::Initialize(Utilities* utilities) //Initialize
Enemies->Initialize(utilities);
Logic->Initialize(utilities);
Player->Initialize(utilities);
Particles->Initialize(utilities);

DisableCursor();

Expand Down Expand Up @@ -129,9 +127,6 @@ bool Game::Load()

bool Game::BeginRun()
{
Particles->SetManagers(Managers);
Player->SetParticleManager(Particles);
Enemies->SetParticleManager(Particles);

//Any Entities added after this point need this method fired manually if needed.

Expand Down
2 changes: 0 additions & 2 deletions Asteroids Reimagined/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "ThePlayer.h"
#include "EnemyControl.h"
#include "TheBackground.h"
#include "Particlemanager.h"

class Game : Common
{
Expand Down Expand Up @@ -38,6 +37,5 @@ class Game : Common
//TheBackground* BackGround = {};
ThePlayer* Player = {};
EnemyControl* Enemies = {};
ParticleManager* Particles = {};
};

2 changes: 2 additions & 0 deletions Asteroids Reimagined/Globals.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "TheManagers.h"
#include "ParticleManager.h"

extern Camera TheCamera;
extern TheManagers Managers;
extern ParticleManager Particles;
extern Vector2 FieldSize;
3 changes: 3 additions & 0 deletions Asteroids Reimagined/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#endif

TheManagers Managers = {};
ParticleManager Particles = {};
Camera TheCamera = {};
Vector2 FieldSize = {};

Expand Down Expand Up @@ -46,6 +47,8 @@ int WinMain()
static Utilities TheUtilities = {};

Managers.EM.SetUtilities(&TheUtilities);
Particles.Initialize(&TheUtilities);
Particles.SetManagers(Managers);

// Define the camera to look into our 3D world.
// Camera position
Expand Down
14 changes: 1 addition & 13 deletions Asteroids Reimagined/TheBoss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ void TheBoss::SetPlayer(ThePlayer* player)
}
}

void TheBoss::SetParticleManager(ParticleManager* particleManager)
{
Particles = particleManager;

for (const auto& turret : Turrets)
{
turret->SetParticleManager(particleManager);
}
}

void TheBoss::SetShieldModel(LineModelPoints model)
{
Shield->SetModel(model);
Expand Down Expand Up @@ -321,7 +311,7 @@ void TheBoss::Hit()

if (!Player->GameOver) PlaySound(ExplodeSound);

Particles->SpawnLineParticles(Position,
Particles.SpawnLineParticles(Position,
Vector3Multiply(Velocity, {0.25f}),
20, 100, 20, 2.0f, WHITE);

Expand Down Expand Up @@ -536,7 +526,6 @@ void TheBoss::FireMissile()
Missiles.back()->SetExplodeSound(MissileExplodeSound);
Missiles.back()->SetOnSound(MissileOnSound);
Missiles.back()->SetPlayer(Player);
Missiles.back()->SetParticleManager(Particles);
Missiles.back()->BeginRun();
}

Expand Down Expand Up @@ -573,7 +562,6 @@ void TheBoss::DropMine()
Managers.EM.AddLineModel(Mines.back(), MineModel);
Mines.back()->SetPlayer(Player);
Mines.back()->SetExplodeSound(MineExplodeSound);
Mines.back()->SetParticleManager(Particles);
Mines.back()->BeginRun();
}

Expand Down
2 changes: 0 additions & 2 deletions Asteroids Reimagined/TheBoss.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class TheBoss : public LineModel
std::vector<Shot*> Shots;

void SetPlayer(ThePlayer* player);
void SetParticleManager(ParticleManager* particleManager);

void SetShieldModel(LineModelPoints model);
void SetTurretModel(LineModelPoints model);
Expand Down Expand Up @@ -98,7 +97,6 @@ class TheBoss : public LineModel
LineModel* RightSpineMount = nullptr;
LineModel* LeftSpineMount = nullptr;

ParticleManager* Particles = nullptr;
ThePlayer* Player = nullptr;

std::vector<Vector3> Path;
Expand Down
7 changes: 1 addition & 6 deletions Asteroids Reimagined/TheBossTurret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ void TheBossTurret::SetPlayer(ThePlayer* player)
Player = player;
}

void TheBossTurret::SetParticleManager(ParticleManager* particleManager)
{
Particles = particleManager;
}

void TheBossTurret::SetShotModel(LineModelPoints model)
{
ShotModel = model;
Expand Down Expand Up @@ -85,7 +80,7 @@ void TheBossTurret::Hit()

if (!Player->GameOver) PlaySound(ExplodeSound);

Particles->SpawnLineParticles(GetWorldPosition(),
Particles.SpawnLineParticles(GetWorldPosition(),
Vector3Multiply(Velocity, {0.25f}),
20, 100, 20, 2.0f, WHITE);

Expand Down
2 changes: 0 additions & 2 deletions Asteroids Reimagined/TheBossTurret.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class TheBossTurret : public LineModel
std::vector<Shot*> Shots;

void SetPlayer(ThePlayer* player);
void SetParticleManager(ParticleManager* particleManager);

void SetShotModel(LineModelPoints model);

Expand Down Expand Up @@ -43,7 +42,6 @@ class TheBossTurret : public LineModel

LineModelPoints ShotModel = {};

ParticleManager* Particles = nullptr;
ThePlayer* Player = nullptr;

void Fire();
Expand Down
8 changes: 0 additions & 8 deletions Asteroids Reimagined/TheDeathStar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ void TheDeathStar::SetSpawnSound(Sound sound)
SpawnSound = sound;
}

void TheDeathStar::SetParticleManager(ParticleManager* particleManager)
{
for (const auto& fighterPair : FighterPairs)
{
fighterPair->SetParticleManager(particleManager);
}
}

void TheDeathStar::SetPlayer(ThePlayer* player)
{
Player = player;
Expand Down
1 change: 0 additions & 1 deletion Asteroids Reimagined/TheDeathStar.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class TheDeathStar : public Enemy

void SetExplodeSound(Sound sound);
void SetSpawnSound(Sound sound);
void SetParticleManager(ParticleManager* particleManager);

bool Initialize(Utilities* utilities);
bool BeginRun();
Expand Down
5 changes: 0 additions & 5 deletions Asteroids Reimagined/TheFighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ void TheFighter::SetExplodeSound(Sound sound)
Enemy::SetExplodeSound(sound);
}

void TheFighter::SetParticleManager(ParticleManager* particleManager)
{
Enemy::SetParticleManager(particleManager);
}

bool TheFighter::Initialize(Utilities* utilities)
{
LineModel::Initialize(TheUtilities);
Expand Down
1 change: 0 additions & 1 deletion Asteroids Reimagined/TheFighter.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class TheFighter : public Enemy
int Wave = 0;

void SetExplodeSound(Sound sound);
void SetParticleManager(ParticleManager* particleManager);

bool Initialize(Utilities* utilities);
bool BeginRun();
Expand Down
8 changes: 0 additions & 8 deletions Asteroids Reimagined/TheFighterPair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ void TheFighterPair::SetExplodeSound(Sound sound)
ExplodeSound = sound;
}

void TheFighterPair::SetParticleManager(ParticleManager* particleManager)
{
for (const auto& fighter : Fighters)
{
fighter->SetParticleManager(particleManager);
}
}

bool TheFighterPair::Initialize(Utilities* utilities)
{
Entity::Initialize(TheUtilities);
Expand Down
1 change: 0 additions & 1 deletion Asteroids Reimagined/TheFighterPair.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class TheFighterPair : public Enemy
void SetWedgeModel(LineModelPoints model);

void SetExplodeSound(Sound sound);
void SetParticleManager(ParticleManager* particleManager);

bool Initialize(Utilities* utilities);
bool BeginRun();
Expand Down
7 changes: 1 addition & 6 deletions Asteroids Reimagined/TheHomingMine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ void TheHomingMine::SetExplodeSound(Sound sound)
ExplodeSound = sound;
}

void TheHomingMine::SetParticleManager(ParticleManager* particles)
{
Particles = particles;
}

bool TheHomingMine::Initialize(Utilities* utilities)
{
LineModel::Initialize(utilities);
Expand Down Expand Up @@ -71,7 +66,7 @@ void TheHomingMine::Hit()
{
if (!GameOver) PlaySound(ExplodeSound);

Particles->SpawnLineParticles(Position, { 0.0f }, Radius * 0.25f, 50, 25, 1.0f, WHITE);
Particles.SpawnLineParticles(Position, { 0.0f }, Radius * 0.25f, 50, 25, 1.0f, WHITE);

Destroy();
}
Expand Down
Loading

0 comments on commit b002a46

Please sign in to comment.