Skip to content

Commit

Permalink
RC 4.52.123 Input optimization, colors, see notes.
Browse files Browse the repository at this point in the history
  • Loading branch information
LanceJZ committed Nov 24, 2024
1 parent e6f8c00 commit deb0f89
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 81 deletions.
69 changes: 34 additions & 35 deletions Asteroids Reimagined/EnemyControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,20 +383,50 @@ void EnemyControl::FixedUpdate()
if (Managers.EM.TimerElapsed(UFOSpawnTimerID)) SpawnUFO();
}

void EnemyControl::NextWave()
{
Wave++;
}

void EnemyControl::NewGame()
{
DeathStar->NewGame();
Reset();

for (const auto& rock : Rocks)
{
rock->Destroy();
}
}

void EnemyControl::NextWave()
void EnemyControl::Reset()
{
Wave++;
BossWave = false;
ClearForBossWave = false;
Wave = 0;
UFOSpawnCount = 0;
RockSpawnCount = StartRockCount;

Managers.EM.ResetTimer(UFOSpawnTimerID, 35.0f);
Managers.EM.ResetTimer(DeathStarSpawnTimerID);

UFOSpawnTimeAmount = 30.0f;
EnemyOneSpawnTimeAmount = 15.0f;
EnemyTwoSpawnTimeAmount = 20.0f;

for (const auto& enemy : EnemyOnes)
{
enemy->Reset();
}

for (const auto& enemy : EnemyTwos)
{
enemy->Reset();
}

for (const auto& ufo : UFOs)
{
ufo->Reset();
}
}

void EnemyControl::SpawnRocks(Vector3 position, int count, TheRock::RockSize size)
Expand Down Expand Up @@ -1010,35 +1040,4 @@ void EnemyControl::HaveHomingMineChaseEnemy()

mine->ChaseEnemy(closestEnemy);
}
}

void EnemyControl::Reset()
{
BossWave = false;
ClearForBossWave = false;
Wave = 0;
UFOSpawnCount = 0;
RockSpawnCount = StartRockCount;

Managers.EM.ResetTimer(UFOSpawnTimerID, 35.0f);
Managers.EM.ResetTimer(DeathStarSpawnTimerID);

UFOSpawnTimeAmount = 30.0f;
EnemyOneSpawnTimeAmount = 15.0f;
EnemyTwoSpawnTimeAmount = 20.0f;

for (const auto& enemy : EnemyOnes)
{
enemy->Reset();
}

for (const auto& enemy : EnemyTwos)
{
enemy->Reset();
}

for (const auto& ufo : UFOs)
{
ufo->Reset();
}
}
}
5 changes: 2 additions & 3 deletions Asteroids Reimagined/EnemyControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ class EnemyControl : public Common
void Update();
void FixedUpdate();

void NewGame();
void NextWave();
void NewGame();
void Reset();

private:
bool NoMoreRocks = false;
Expand Down Expand Up @@ -145,6 +146,4 @@ class EnemyControl : public Common
void MakeReadyForBossWave();
void DoBossStuff();
void HaveHomingMineChaseEnemy();

void Reset();
};
2 changes: 1 addition & 1 deletion Asteroids Reimagined/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void Game::Draw2D()
{

}

// For Game Input when game is paused or not.
void Game::GameInput()
{
Logic->GameInput();
Expand Down
15 changes: 14 additions & 1 deletion Asteroids Reimagined/GameLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void GameLogic::FixedUpdate()
}
}
}

//For Game Input when game is paused or not.
void GameLogic::GameInput()
{
if (State == Pause)
Expand Down Expand Up @@ -209,6 +209,18 @@ void GameLogic::GameInput()
}
#endif
}

if (IsKeyPressed(KEY_I))
{
if (Player->AltMouseMode)
{
Player->AltMouseMode = false;
}
else
{
Player->AltMouseMode = true;
}
}
}

void GameLogic::SpawnPowerUp(Vector3 position)
Expand Down Expand Up @@ -290,6 +302,7 @@ void GameLogic::AddPlayerShipModels(int number)
void GameLogic::NewGame()
{
Player->NewGame();
Enemies->Reset();
Enemies->NewGame();
HighScores->Reset();

Expand Down
17 changes: 9 additions & 8 deletions 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.50.123");
InitWindow(windowWidth, windowHeight, "Asteroids Reimagined - RC 4.52.123");
InitAudioDevice();

Image icon = LoadImage("icon.png");
Expand All @@ -41,7 +41,7 @@ int WinMain()

if (IsWindowState(FLAG_VSYNC_HINT)) ClearWindowState(FLAG_VSYNC_HINT);
glfwSwapInterval(0);
SetTargetFPS(200);
SetTargetFPS(120);

static Utilities TheUtilities = {};

Expand Down Expand Up @@ -69,22 +69,23 @@ int WinMain()

while (!WindowShouldClose())
{
game.ProcessInput();

if (game.Logic->State != GameState::Pause)
{
Managers.EM.Input();

float deltaTime = GetFrameTime() * 0.5f;
float fixedDeltaTime = deltaTime * 2.0f;

Managers.EM.Update(deltaTime);
game.Update(deltaTime);
Managers.EM.Update(deltaTime);
game.Update(deltaTime);
Managers.EM.FixedUpdate(deltaTime * 2.0f);
game.FixedUpdate(deltaTime * 2.0f);

Managers.EM.Input();
Managers.EM.FixedUpdate(fixedDeltaTime);
game.FixedUpdate(fixedDeltaTime);
}

game.ProcessInput();

BeginDrawing();
ClearBackground({ 8, 2, 16, 100 });
BeginMode3D(TheCamera);
Expand Down
Loading

0 comments on commit deb0f89

Please sign in to comment.