Skip to content

Commit

Permalink
RC 4.37.97 and Cleaned up some of the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
LanceJZ committed Oct 10, 2024
1 parent 76c6383 commit 855ae5c
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 46 deletions.
3 changes: 1 addition & 2 deletions Asteroids Reimagined/Enemy1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ void Enemy1::FireMissile() //TODO: Move common parts to Enemy class.
if (spawnMissile)
{
Missiles.push_back(DBG_NEW TheMissile());
Managers.EM.AddLineModel(Missiles.back());
Missiles.back()->SetModel(MissileModel);
Managers.EM.AddLineModel(Missiles.back(), MissileModel);
Missiles.back()->SetPlayer(Player);
Missiles.back()->SetParticleManager(Particles);
Missiles.back()->SetOnSound(MissileOnSound);
Expand Down
15 changes: 7 additions & 8 deletions Asteroids Reimagined/Enemy2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Enemy2::Enemy2()
{
LayMineTimerID = Managers.EM.AddTimer(4.75f);
MineDropTimerID = Managers.EM.AddTimer(4.75f);
}

Enemy2::~Enemy2()
Expand Down Expand Up @@ -59,7 +59,7 @@ void Enemy2::Update(float deltaTime)

SetRotateVelocity(Destination, TurnSpeed, Speed);

if (Managers.EM.TimerElapsed(LayMineTimerID))
if (Managers.EM.TimerElapsed(MineDropTimerID))
{
DropMine();
}
Expand All @@ -76,7 +76,7 @@ void Enemy2::Draw3D()

void Enemy2::Spawn()
{
Managers.EM.ResetTimer(LayMineTimerID, MineDropTimeAmount = 4.75f);
Managers.EM.ResetTimer(MineDropTimerID, MineDropTimeAmount = 4.75f);

Enemy::Spawn();
}
Expand All @@ -102,7 +102,7 @@ void Enemy2::Reset()
{
Destroy();

Managers.EM.ResetTimer(LayMineTimerID, MineDropTimeAmount = 4.75f);
Managers.EM.ResetTimer(MineDropTimerID, MineDropTimeAmount = 4.75f);

for (const auto& mine : Mines)
{
Expand Down Expand Up @@ -140,7 +140,7 @@ void Enemy2::DropMine()

float dropTime = GetRandomFloat(min, max);

Managers.EM.ResetTimer(LayMineTimerID, dropTime);
Managers.EM.ResetTimer(MineDropTimerID, dropTime);

for (size_t i = 0; i < mineNumber; i++)
{
Expand All @@ -155,10 +155,9 @@ void Enemy2::DropMine()
if (spawnNewMine)
{
Mines.push_back(DBG_NEW TheMine());
Managers.EM.AddLineModel(Mines.back());
Managers.EM.AddLineModel(Mines.back(), MineModel);
Mines.back()->SetPlayer(Player);
Mines.back()->SetModel(MineModel);
Mines.back()->SetExplodeSound(ExplodeSound);
Mines.back()->SetExplodeSound(MineExplodeSound);
Mines.back()->SetParticleManager(Particles);
Mines.back()->BeginRun();
}
Expand Down
2 changes: 1 addition & 1 deletion Asteroids Reimagined/Enemy2.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Enemy2 : public Enemy
void Reset();

private:
size_t LayMineTimerID = 0;
size_t MineDropTimerID = 0;

float Speed = 75.0f;
float TurnSpeed = 0.4666f;
Expand Down
53 changes: 20 additions & 33 deletions Asteroids Reimagined/EnemyControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@ void EnemyControl::SetEnemyOneSpawnSound(Sound sound)
void EnemyControl::SetEnemyOneFireSound(Sound sound)
{
EnemyOneFireSound = sound;
Boss->SetMissileFireSound(sound);
}

void EnemyControl::SetEnemyOneMissileOnSound(Sound sound)
{
EnemyOneMissileOnSound = sound;
Boss->SetMissileOnSound(sound);
}

void EnemyControl::SetEnemyOneExplodeSound(Sound sound)
Expand All @@ -159,6 +161,7 @@ void EnemyControl::SetEnemyOneOnSound(Sound sound)
void EnemyControl::SetEnemyOneMissileExplodeSound(Sound sound)
{
EnemyOneMissileExplodeSound = sound;
Boss->SetMissileExplodeSound(sound);
}

void EnemyControl::SetEnemyTwoSpawnSound(Sound sound)
Expand All @@ -169,6 +172,7 @@ void EnemyControl::SetEnemyTwoSpawnSound(Sound sound)
void EnemyControl::SetEnemyTwoFireSound(Sound sound)
{
EnemyTwoFireSound = sound;
Boss->SetMineDropSound(sound);
}

void EnemyControl::SetEnemyTwoExplodeSound(Sound sound)
Expand All @@ -184,6 +188,7 @@ void EnemyControl::SetEnemyTwoOnSound(Sound sound)
void EnemyControl::SetEnemyTwoMineExplodeSound(Sound sound)
{
EnemyTwoMineExplodeSound = sound;
Boss->SetMineExplodeSound(sound);
}

void EnemyControl::SetBossExplodeSound(Sound sound)
Expand Down Expand Up @@ -385,8 +390,8 @@ void EnemyControl::SpawnRocks(Vector3 position, int count, TheRock::RockSize siz
{
size_t rockType = GetRandomValue(0, 3);
Rocks.push_back(DBG_NEW TheRock());
Managers.EM.AddLineModel(Rocks.back());
Rocks.back()->SetModel((RockModels[rockType]));
Managers.EM.AddLineModel(Rocks.back(), (RockModels[rockType]));
//Rocks.back()->SetModel((RockModels[rockType]));
Rocks.back()->SetPlayer(Player);
Rocks.back()->SetExplodeSound(RockExplodeSound);
Rocks.back()->BeginRun();
Expand Down Expand Up @@ -436,16 +441,14 @@ void EnemyControl::SpawnUFO()
if (spawnUFO)
{
UFOs.push_back(DBG_NEW TheUFO());
Managers.EM.AddLineModel(UFOs.back());
UFOs.back()->SetModel(UFOModel);
Managers.EM.AddLineModel(UFOs.back(), UFOModel);
UFOs.back()->SetShotModel(ShotModel);
UFOs.back()->SetExplodeSound(UFOExplodeSound);
UFOs.back()->SetFireSound(UFOFireSound);
UFOs.back()->SetBigSound(UFOBigSound);
UFOs.back()->SetSmallSound(UFOSmallSound);
UFOs.back()->SetPlayer(Player);
UFOs.back()->SetParticleManager(Particles);
UFOs.back()->Initialize(TheUtilities);
UFOs.back()->BeginRun();

for (const auto& enemy : EnemyOnes)
Expand Down Expand Up @@ -496,8 +499,7 @@ void EnemyControl::SpawnEnemyOne()
if (spawnOne)
{
EnemyOnes.push_back(DBG_NEW Enemy1());
Managers.EM.AddLineModel(EnemyOnes.back());
EnemyOnes.back()->SetModel(EnemyOneModel);
Managers.EM.AddLineModel(EnemyOnes.back(), EnemyOneModel);
EnemyOnes.back()->SetShotModel(ShotModel);
EnemyOnes.back()->SetMissileModel(MissileModel);
EnemyOnes.back()->SetSpawnSound(EnemyOneSpawnSound);
Expand All @@ -508,7 +510,6 @@ void EnemyControl::SpawnEnemyOne()
EnemyOnes.back()->SetMissileOnSound(EnemyOneMissileOnSound);
EnemyOnes.back()->SetPlayer(Player);
EnemyOnes.back()->SetParticleManager(Particles);
EnemyOnes.back()->Initialize(TheUtilities);
EnemyOnes.back()->BeginRun();
}

Expand Down Expand Up @@ -559,8 +560,7 @@ void EnemyControl::SpawnEnemyTwo()
if (spawnOne)
{
EnemyTwos.push_back(DBG_NEW Enemy2());
Managers.EM.AddLineModel(EnemyTwos.back());
EnemyTwos.back()->SetModel(EnemyTwoModel);
Managers.EM.AddLineModel(EnemyTwos.back(), EnemyTwoModel);
EnemyTwos.back()->SetShotModel(ShotModel);
EnemyTwos.back()->SetMineModel(MineModel);
EnemyTwos.back()->SetSpawnSound(EnemyTwoSpawnSound);
Expand All @@ -569,7 +569,6 @@ void EnemyControl::SpawnEnemyTwo()
EnemyTwos.back()->SetOnSound(EnemyTwoOnSound);
EnemyTwos.back()->SetPlayer(Player);
EnemyTwos.back()->SetParticleManager(Particles);
EnemyTwos.back()->Initialize(TheUtilities);
EnemyTwos.back()->BeginRun();
}

Expand Down Expand Up @@ -643,8 +642,8 @@ void EnemyControl::SpawnBoss()
{
Vector3 position = {0.0f, 0.0f, 0.0f };
float rotation = 0;
float width = Boss->WindowWidth * 0.75f;
float height = Boss->WindowHeight * 0.75f;
float width = Boss->WindowWidth * 0.95f;
float height = Boss->WindowHeight * 0.95f;

int option = GetRandomValue(0, 3);

Expand Down Expand Up @@ -926,9 +925,8 @@ void EnemyControl::HaveHomingMineChaseEnemy()
{
if (!mine->Enabled) continue;

bool enemyToChase = false;
float distance = 450.0f;
Vector3 enemyPosition = { 0.0f, 0.0f, 0.0f };
Entity *closestEnemy = nullptr;

for (const auto& ufo : UFOs)
{
Expand All @@ -939,39 +937,36 @@ void EnemyControl::HaveHomingMineChaseEnemy()
if (ufoDistance < distance)
{
distance = ufoDistance;
enemyToChase = true;
enemyPosition = ufo->Position;
closestEnemy = ufo;
break;
}
}

for (const auto& enemy : EnemyOnes)
{
if (enemy->Enabled && !enemyToChase)
if (enemy->Enabled)
{
float enemyOneDistance = Vector3Distance(enemy->Position, mine->Position);

if (enemyOneDistance < distance)
{
distance = enemyOneDistance;
enemyToChase = true;
enemyPosition = enemy->Position;
closestEnemy = enemy;
break;
}
}
}

for (const auto& enemy : EnemyTwos)
{
if (enemy->Enabled && !enemyToChase)
if (enemy->Enabled)
{
float enemyTwoDistance = Vector3Distance(enemy->Position, mine->Position);

if (enemyTwoDistance < distance)
{
distance = enemyTwoDistance;
enemyToChase = true;
enemyPosition = enemy->Position;
closestEnemy = enemy;
break;
}
}
Expand All @@ -984,20 +979,12 @@ void EnemyControl::HaveHomingMineChaseEnemy()

if (deathStarDistance < distance)
{
enemyPosition = DeathStar->GetWorldPosition();
enemyToChase = true;
closestEnemy = DeathStar;
}

}

if (enemyToChase)
{
mine->ChaseEnemy(enemyPosition);
}
else
{
mine->LostEnemy();
}
mine->ChaseEnemy(closestEnemy);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Asteroids Reimagined/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int WinMain()
int windowHeight = 960; //height
int windowWidth = 1280; //width

InitWindow(windowWidth, windowHeight, "Asteroids Reimagined - RC 4.27.97");
InitWindow(windowWidth, windowHeight, "Asteroids Reimagined - RC 4.37.97");
InitAudioDevice();

Image icon = LoadImage("icon.png");
Expand Down
93 changes: 93 additions & 0 deletions Asteroids Reimagined/TheBoss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,31 @@ void TheBoss::SetSpineFireSound(Sound sound)
SpineFireSound = sound;
}

void TheBoss::SetMissileFireSound(Sound sound)
{
MissileFireSound = sound;
}

void TheBoss::SetMissileOnSound(Sound sound)
{
MissileOnSound = sound;
}

void TheBoss::SetMissileExplodeSound(Sound sound)
{
MissileExplodeSound = sound;
}

void TheBoss::SetMineDropSound(Sound sound)
{
MineDropSound = sound;
}

void TheBoss::SetMineExplodeSound(Sound sound)
{
MineExplodeSound = sound;
}

bool TheBoss::Initialize(Utilities* utilities)
{
LineModel::Initialize(utilities);
Expand Down Expand Up @@ -263,6 +288,9 @@ void TheBoss::Spawn(Vector3 position, float rotation)
{
turret->Spawn();
}

Managers.EM.SetTimer(MissileFireTimerID, 2.5f);
Managers.EM.SetTimer(MineDropTimerID, 2.0f);
}

void TheBoss::Hit()
Expand Down Expand Up @@ -454,10 +482,75 @@ void TheBoss::FireShots()

void TheBoss::FireMissile()
{
float missileFireTime = 1.25f;

Managers.EM.ResetTimer(MissileFireTimerID, missileFireTime);

if (!Player->Enabled) return;

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

bool spawnMissile = true;
size_t missileNumber = Missiles.size();

for (size_t check = 0; check < missileNumber; check++)
{
if (!Missiles.at(check)->Enabled)
{
spawnMissile = false;
missileNumber = check;
}
}

if (spawnMissile)
{
Missiles.push_back(DBG_NEW TheMissile());
Managers.EM.AddLineModel(Missiles.back(), MissileModel);
Missiles.back()->SetExplodeSound(MissileExplodeSound);
Missiles.back()->SetOnSound(MissileOnSound);
Missiles.back()->SetPlayer(Player);
Missiles.back()->SetParticleManager(Particles);
Missiles.back()->BeginRun();
}

Missiles.at(missileNumber)->Spawn(Position);
Missiles.at(missileNumber)->RotationZ = RotationZ;
}

void TheBoss::DropMine()
{
float dropTime = 1.15f;

Managers.EM.ResetTimer(MineDropTimerID, dropTime);

if (!Player->Enabled) return;

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

size_t mineNumber = Mines.size();
bool spawnNewMine = true;

for (size_t i = 0; i < mineNumber; i++)
{
if (Mines.at(i)->Enabled == false)
{
spawnNewMine = false;
mineNumber = i;
break;
}
}

if (spawnNewMine)
{
Mines.push_back(DBG_NEW TheMine());
Managers.EM.AddLineModel(Mines.back(), MineModel);
Mines.back()->SetPlayer(Player);
Mines.back()->SetExplodeSound(MineExplodeSound);
Mines.back()->SetParticleManager(Particles);
Mines.back()->BeginRun();
}

Mines.at(mineNumber)->Spawn(Position);
}

void TheBoss::ShieldHit(int damage)
Expand Down
Loading

0 comments on commit 855ae5c

Please sign in to comment.