diff --git a/Asteroids Reimagined/Enemy.cpp b/Asteroids Reimagined/Enemy.cpp index 73b5235..b617395 100644 --- a/Asteroids Reimagined/Enemy.cpp +++ b/Asteroids Reimagined/Enemy.cpp @@ -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); @@ -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); diff --git a/Asteroids Reimagined/Enemy.h b/Asteroids Reimagined/Enemy.h index d9f1725..ea7de7c 100644 --- a/Asteroids Reimagined/Enemy.h +++ b/Asteroids Reimagined/Enemy.h @@ -2,7 +2,6 @@ #include "Globals.h" #include "ThePlayer.h" #include "Shot.h" -#include "ParticleManager.h" class Enemy : public LineModel { @@ -20,7 +19,6 @@ class Enemy : public LineModel std::vector Enemy2Refs; void SetPlayer(ThePlayer* player); - void SetParticleManager(ParticleManager* particleManager); void SetShotModel(LineModelPoints model); @@ -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 = {}; diff --git a/Asteroids Reimagined/Enemy1.cpp b/Asteroids Reimagined/Enemy1.cpp index ddc6fe2..4118787 100644 --- a/Asteroids Reimagined/Enemy1.cpp +++ b/Asteroids Reimagined/Enemy1.cpp @@ -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(); diff --git a/Asteroids Reimagined/Enemy2.cpp b/Asteroids Reimagined/Enemy2.cpp index 6c81d7b..3dd76bb 100644 --- a/Asteroids Reimagined/Enemy2.cpp +++ b/Asteroids Reimagined/Enemy2.cpp @@ -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(); } diff --git a/Asteroids Reimagined/EnemyControl.cpp b/Asteroids Reimagined/EnemyControl.cpp index b6d45f0..260355f 100644 --- a/Asteroids Reimagined/EnemyControl.cpp +++ b/Asteroids Reimagined/EnemyControl.cpp @@ -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); @@ -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) @@ -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(); } @@ -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(); } @@ -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); diff --git a/Asteroids Reimagined/EnemyControl.h b/Asteroids Reimagined/EnemyControl.h index f9d86b9..60073d1 100644 --- a/Asteroids Reimagined/EnemyControl.h +++ b/Asteroids Reimagined/EnemyControl.h @@ -7,7 +7,6 @@ #include "Enemy1.h" #include "Enemy2.h" #include "TheBoss.h" -#include "ParticleManager.h" class EnemyControl : public Common { @@ -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(); @@ -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(); diff --git a/Asteroids Reimagined/Game.cpp b/Asteroids Reimagined/Game.cpp index be6efd3..0f331a2 100644 --- a/Asteroids Reimagined/Game.cpp +++ b/Asteroids Reimagined/Game.cpp @@ -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() @@ -23,7 +22,6 @@ bool Game::Initialize(Utilities* utilities) //Initialize Enemies->Initialize(utilities); Logic->Initialize(utilities); Player->Initialize(utilities); - Particles->Initialize(utilities); DisableCursor(); @@ -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. diff --git a/Asteroids Reimagined/Game.h b/Asteroids Reimagined/Game.h index 8ca5520..40622ef 100644 --- a/Asteroids Reimagined/Game.h +++ b/Asteroids Reimagined/Game.h @@ -5,7 +5,6 @@ #include "ThePlayer.h" #include "EnemyControl.h" #include "TheBackground.h" -#include "Particlemanager.h" class Game : Common { @@ -38,6 +37,5 @@ class Game : Common //TheBackground* BackGround = {}; ThePlayer* Player = {}; EnemyControl* Enemies = {}; - ParticleManager* Particles = {}; }; diff --git a/Asteroids Reimagined/Globals.h b/Asteroids Reimagined/Globals.h index b4dbdc5..d917cce 100644 --- a/Asteroids Reimagined/Globals.h +++ b/Asteroids Reimagined/Globals.h @@ -1,5 +1,7 @@ #include "TheManagers.h" +#include "ParticleManager.h" extern Camera TheCamera; extern TheManagers Managers; +extern ParticleManager Particles; extern Vector2 FieldSize; \ No newline at end of file diff --git a/Asteroids Reimagined/Main.cpp b/Asteroids Reimagined/Main.cpp index 39f4c16..5cbe708 100644 --- a/Asteroids Reimagined/Main.cpp +++ b/Asteroids Reimagined/Main.cpp @@ -18,6 +18,7 @@ #endif TheManagers Managers = {}; +ParticleManager Particles = {}; Camera TheCamera = {}; Vector2 FieldSize = {}; @@ -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 diff --git a/Asteroids Reimagined/TheBoss.cpp b/Asteroids Reimagined/TheBoss.cpp index 787b124..b9d0760 100644 --- a/Asteroids Reimagined/TheBoss.cpp +++ b/Asteroids Reimagined/TheBoss.cpp @@ -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); @@ -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); @@ -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(); } @@ -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(); } diff --git a/Asteroids Reimagined/TheBoss.h b/Asteroids Reimagined/TheBoss.h index 86e08ed..c73d640 100644 --- a/Asteroids Reimagined/TheBoss.h +++ b/Asteroids Reimagined/TheBoss.h @@ -22,7 +22,6 @@ class TheBoss : public LineModel std::vector Shots; void SetPlayer(ThePlayer* player); - void SetParticleManager(ParticleManager* particleManager); void SetShieldModel(LineModelPoints model); void SetTurretModel(LineModelPoints model); @@ -98,7 +97,6 @@ class TheBoss : public LineModel LineModel* RightSpineMount = nullptr; LineModel* LeftSpineMount = nullptr; - ParticleManager* Particles = nullptr; ThePlayer* Player = nullptr; std::vector Path; diff --git a/Asteroids Reimagined/TheBossTurret.cpp b/Asteroids Reimagined/TheBossTurret.cpp index c85ffca..f919ea7 100644 --- a/Asteroids Reimagined/TheBossTurret.cpp +++ b/Asteroids Reimagined/TheBossTurret.cpp @@ -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; @@ -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); diff --git a/Asteroids Reimagined/TheBossTurret.h b/Asteroids Reimagined/TheBossTurret.h index 2889293..4d61a3b 100644 --- a/Asteroids Reimagined/TheBossTurret.h +++ b/Asteroids Reimagined/TheBossTurret.h @@ -12,7 +12,6 @@ class TheBossTurret : public LineModel std::vector Shots; void SetPlayer(ThePlayer* player); - void SetParticleManager(ParticleManager* particleManager); void SetShotModel(LineModelPoints model); @@ -43,7 +42,6 @@ class TheBossTurret : public LineModel LineModelPoints ShotModel = {}; - ParticleManager* Particles = nullptr; ThePlayer* Player = nullptr; void Fire(); diff --git a/Asteroids Reimagined/TheDeathStar.cpp b/Asteroids Reimagined/TheDeathStar.cpp index b9dbec4..711a139 100644 --- a/Asteroids Reimagined/TheDeathStar.cpp +++ b/Asteroids Reimagined/TheDeathStar.cpp @@ -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; diff --git a/Asteroids Reimagined/TheDeathStar.h b/Asteroids Reimagined/TheDeathStar.h index f540353..104bde8 100644 --- a/Asteroids Reimagined/TheDeathStar.h +++ b/Asteroids Reimagined/TheDeathStar.h @@ -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(); diff --git a/Asteroids Reimagined/TheFighter.cpp b/Asteroids Reimagined/TheFighter.cpp index 79033cb..3c5a27e 100644 --- a/Asteroids Reimagined/TheFighter.cpp +++ b/Asteroids Reimagined/TheFighter.cpp @@ -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); diff --git a/Asteroids Reimagined/TheFighter.h b/Asteroids Reimagined/TheFighter.h index a8ef6c7..d810cbc 100644 --- a/Asteroids Reimagined/TheFighter.h +++ b/Asteroids Reimagined/TheFighter.h @@ -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(); diff --git a/Asteroids Reimagined/TheFighterPair.cpp b/Asteroids Reimagined/TheFighterPair.cpp index 706e7f2..d34bc0b 100644 --- a/Asteroids Reimagined/TheFighterPair.cpp +++ b/Asteroids Reimagined/TheFighterPair.cpp @@ -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); diff --git a/Asteroids Reimagined/TheFighterPair.h b/Asteroids Reimagined/TheFighterPair.h index b691998..d90d6b2 100644 --- a/Asteroids Reimagined/TheFighterPair.h +++ b/Asteroids Reimagined/TheFighterPair.h @@ -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(); diff --git a/Asteroids Reimagined/TheHomingMine.cpp b/Asteroids Reimagined/TheHomingMine.cpp index 8eb16b0..08274bd 100644 --- a/Asteroids Reimagined/TheHomingMine.cpp +++ b/Asteroids Reimagined/TheHomingMine.cpp @@ -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); @@ -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(); } diff --git a/Asteroids Reimagined/TheHomingMine.h b/Asteroids Reimagined/TheHomingMine.h index a4c1ef1..b4be286 100644 --- a/Asteroids Reimagined/TheHomingMine.h +++ b/Asteroids Reimagined/TheHomingMine.h @@ -1,6 +1,5 @@ #pragma once #include "Globals.h" -#include "ParticleManager.h" class TheHomingMine : public LineModel { @@ -11,7 +10,6 @@ class TheHomingMine : public LineModel bool GameOver = false; void SetExplodeSound(Sound sound); - void SetParticleManager(ParticleManager* particles); bool Initialize(Utilities* utilities); bool BeginRun(); @@ -33,7 +31,5 @@ class TheHomingMine : public LineModel Sound ExplodeSound = {}; - ParticleManager* Particles = nullptr; - Entity* Target = nullptr; }; diff --git a/Asteroids Reimagined/TheMine.h b/Asteroids Reimagined/TheMine.h index 90d1484..597fd4e 100644 --- a/Asteroids Reimagined/TheMine.h +++ b/Asteroids Reimagined/TheMine.h @@ -1,7 +1,6 @@ #pragma once #include "Globals.h" #include "ThePlayer.h" -#include "ParticleManager.h" #include "Enemy.h" class TheMine : public Enemy diff --git a/Asteroids Reimagined/ThePlayer.cpp b/Asteroids Reimagined/ThePlayer.cpp index f720b2a..d2c9635 100644 --- a/Asteroids Reimagined/ThePlayer.cpp +++ b/Asteroids Reimagined/ThePlayer.cpp @@ -146,11 +146,6 @@ void ThePlayer::SetMineExplodeSound(Sound sound) MineExplodeSound = sound; } -void ThePlayer::SetParticleManager(ParticleManager* particleManager) -{ - Particles = particleManager; -} - void ThePlayer::SetCrosshairModel(LineModelPoints model) { Crosshair->SetModel(model); @@ -288,7 +283,7 @@ void ThePlayer::Hit(Vector3 location, Vector3 velocity) Entity::Hit(); PlaySound(ExplodeSound); - Particles->SpawnLineParticles(Position, Vector3Multiply(Velocity, { 0.25f }), + Particles.SpawnLineParticles(Position, Vector3Multiply(Velocity, { 0.25f }), Radius * 0.25f, 30.0f, 40, 3.0f, WHITE); Acceleration = { 0 }; Velocity = { 0 }; @@ -749,7 +744,6 @@ void ThePlayer::DropHomingMine() Mines.back()->SetModel(MineModel); Mines.back()->ModelColor = GRAY; Mines.back()->SetExplodeSound(MineExplodeSound); - Mines.back()->SetParticleManager(Particles); Mines.back()->BeginRun(); } diff --git a/Asteroids Reimagined/ThePlayer.h b/Asteroids Reimagined/ThePlayer.h index 4c66ed9..1a96133 100644 --- a/Asteroids Reimagined/ThePlayer.h +++ b/Asteroids Reimagined/ThePlayer.h @@ -5,7 +5,6 @@ #include "TheHomingMine.h" #include "ThePlasmaShot.h" #include "TheScore.h" -#include "ParticleManager.h" enum SecondaryWeaponType { @@ -150,7 +149,6 @@ class ThePlayer : public LineModel LineModelPoints BigShotModel; TheScore* Score = {}; - ParticleManager* Particles = {}; std::vector AmmoMeterModels = {}; diff --git a/Asteroids Reimagined/TheUFO.h b/Asteroids Reimagined/TheUFO.h index 2cbd8fb..d69baf8 100644 --- a/Asteroids Reimagined/TheUFO.h +++ b/Asteroids Reimagined/TheUFO.h @@ -3,7 +3,6 @@ #include "Enemy.h" #include "ThePlayer.h" #include "Shot.h" -#include "ParticleManager.h" class TheUFO : public Enemy { diff --git a/README.md b/README.md index 79cfa63..6212465 100644 --- a/README.md +++ b/README.md @@ -100,4 +100,5 @@ Added math_operators.h to Knightmare Engine. Reworked Knightmare Engine so that it has three separate frame time hits, Update, FixedUpdate and Render. Disabled until fixed. Knightmare Engine Update, optimizations were made. Using raylib 5.5 release now. Collisions are much more accurate now. Update is divided into half and run twice for each render. So that collisions are checked twice every frame, with half the movement. -Optimizations on keyboard/mouse/controller input. Added new mouse controls, can switch using the I button at any time. \ No newline at end of file +Optimizations on keyboard/mouse/controller input. Added new mouse controls, can switch using the I button at any time. +Changed Particles, made it Global. \ No newline at end of file