diff --git a/OLCCodeJam2020-The-Great-Machine.zip b/OLCCodeJam2020-The-Great-Machine.zip deleted file mode 100644 index 99f768b..0000000 Binary files a/OLCCodeJam2020-The-Great-Machine.zip and /dev/null differ diff --git a/TODO b/TODO index 082d6ab..db57953 100644 --- a/TODO +++ b/TODO @@ -10,6 +10,7 @@ [d] Fix collision [x] Better player spritesheet [x] Animation system +[x] Sound [ ] Enemies / AI [ ] Dungeon fixed entity spawning [ ] Enemy AI diff --git a/The Great Machine.exe b/The Great Machine.exe index 1e5915a..ad3e534 100644 Binary files a/The Great Machine.exe and b/The Great Machine.exe differ diff --git a/The Great Machine/Collisions.cpp b/The Great Machine/Collisions.cpp index 2f9fc34..9c7cdb9 100644 --- a/The Great Machine/Collisions.cpp +++ b/The Great Machine/Collisions.cpp @@ -15,7 +15,7 @@ bool EntityCollide(Entity* entity, std::vector& nearby, int tileSize, Col static Logger& _Logger = Logger::getInstance(); - engine->SetDrawTarget(uint8_t(0)); + engine->SetDrawTarget(1); engine->Clear(olc::BLANK); float entityX = static_cast(entity->Coords.x - entity->TrackingCamera->Coords.x); @@ -28,12 +28,12 @@ bool EntityCollide(Entity* entity, std::vector& nearby, int tileSize, Col int entityTop = static_cast(entityY); int entityBottom = static_cast(entityY + entityH); - if (ShowDebug) + if (ShowCollisionDebug) engine->DrawRect(entityX, entityY, entityW, entityH, olc::RED); for (auto tile : nearby) { - if (ShowDebug) + if (ShowCollisionDebug) engine->DrawRect({ static_cast(static_cast((tile->Coords.x * tileSize) - entity->TrackingCamera->Coords.x)), static_cast(static_cast((tile->Coords.y * tileSize) - entity->TrackingCamera->Coords.y)) }, {tileSize, tileSize}, olc::BLUE); // return if not collidable @@ -51,7 +51,7 @@ bool EntityCollide(Entity* entity, std::vector& nearby, int tileSize, Col bool collision = xOverlaps && yOverlaps; - if (ShowDebug) + if (ShowCollisionDebug) engine->FillRect({static_cast(static_cast((tile->Coords.x * tileSize) - entity->TrackingCamera->Coords.x)), static_cast(static_cast((tile->Coords.y * tileSize) - entity->TrackingCamera->Coords.y))}, {tileSize, tileSize}, collision ? olc::RED : olc::BLUE); if (!collision) continue; diff --git a/The Great Machine/Dungeon.cpp b/The Great Machine/Dungeon.cpp index a818356..376c2df 100644 --- a/The Great Machine/Dungeon.cpp +++ b/The Great Machine/Dungeon.cpp @@ -14,7 +14,6 @@ void PerlinNoise1D(int nCount, float *fSeed, int nOctaves, float fBias, float *fOutput) { - // Used 1D Perlin Noise for (int x = 0; x < nCount; x++) { float fNoise = 0.0f; @@ -80,7 +79,21 @@ Dungeon::Dungeon() Player->Type = EEntity::Type::Player; // Relative to player TL corner // not really used ? lol - Player->HitBox = new Collider{ 0, 0, 28, 36 } ; + Player->HitBox = new Collider{ 0, 0, 28, 36 }; + + EnemyRenderable = new olc::Renderable(); + EnemyRenderable->Load("res/player.png"); + EnemyAnimator = new olc::AnimatedSprite(); + EnemyAnimator->mode = olc::AnimatedSprite::SPRITE_MODE::SINGLE; + EnemyAnimator->type = olc::AnimatedSprite::SPRITE_TYPE::DECAL; + EnemyAnimator->spriteSheet = EnemyRenderable; + EnemyAnimator->SetSpriteSize({28, 36}); + + EnemyAnimator->AddState("idle", 0.127f, olc::AnimatedSprite::PLAY_MODE::LOOP, std::vector{ + {28, 0} + }); + EnemyAnimator->SetState("idle"); + Player->Renderable = new olc::Renderable(); Player->Renderable->Load("res/player.png"); @@ -90,29 +103,29 @@ Dungeon::Dungeon() Player->Animator->spriteSheet = Player->Renderable; Player->Animator->SetSpriteSize({28, 36}); - Player->Animator->AddState("idle", std::vector{ + Player->Animator->AddState("idle", 0.127f, olc::AnimatedSprite::PLAY_MODE::LOOP, std::vector{ {28, 0} }); - Player->Animator->AddState("north", std::vector{ + Player->Animator->AddState("north", 0.127f, olc::AnimatedSprite::PLAY_MODE::LOOP, std::vector{ {0, 110}, {28, 110}, {56, 110}, {84, 110} }); - Player->Animator->AddState("east", std::vector{ + Player->Animator->AddState("east", 0.127f, olc::AnimatedSprite::PLAY_MODE::LOOP, std::vector{ {0, 36}, {28, 36}, {56, 36}, {84, 36} }); - Player->Animator->AddState("south", std::vector{ + Player->Animator->AddState("south", 0.127f, olc::AnimatedSprite::PLAY_MODE::LOOP, std::vector{ {0, 0}, {28, 0}, {56, 0}, {84, 0} }); - Player->Animator->AddState("west", std::vector{ + Player->Animator->AddState("west", 0.127f, olc::AnimatedSprite::PLAY_MODE::LOOP, std::vector{ {0, 72}, {28, 72}, {56, 72}, @@ -133,6 +146,27 @@ Dungeon::Dungeon() FireOverlay = new olc::Renderable(); FireOverlay->Load("res/torch.png"); + SoundBufferFireLighting.loadFromFile("res/fire_start.wav"); + SoundFireLighting.setBuffer(SoundBufferFireLighting); + SoundFireLighting.setLoop(false); + SoundFireLighting.setVolume(50.f); + + SoundBufferFire.loadFromFile("res/fire.wav"); + SoundFire.setBuffer(SoundBufferFire); + SoundFire.setLoop(true); + SoundFire.setVolume(100.f); + + SoundBufferAmbient.loadFromFile("res/ambient.ogg"); + SoundAmbient.setBuffer(SoundBufferAmbient); + SoundAmbient.setLoop(true); + SoundAmbient.play(); + + SoundBufferFootsteps.loadFromFile("res/run.ogg"); + SoundFootsteps.setBuffer(SoundBufferFootsteps); + SoundFootsteps.setLoop(true); + SoundFootsteps.setVolume(20.f); + + } void Dungeon::Generate() @@ -283,11 +317,6 @@ void Dungeon::Generate() } } -void Dungeon::SpawnEntity(Entity* entity) -{ - Entities[entity->Coords] = entity; -} - void Dungeon::Input(olc::PixelGameEngine* engine, float fTime) { @@ -295,30 +324,36 @@ void Dungeon::Input(olc::PixelGameEngine* engine, float fTime) static std::string state = "idle"; static std::string lastState = "idle"; + static bool WasMoving = false; + bool IsMoving = false; if (engine->GetKey(olc::W).bHeld) { Player->Coords.y -= static_cast(TileSize) * (fTime * Player->Speed); if (state != "north") state = "north"; + IsMoving = true; } if (engine->GetKey(olc::A).bHeld) { Player->Coords.x -= static_cast(TileSize) * (fTime * Player->Speed); if (state != "west") state = "west"; + IsMoving = true; } if (engine->GetKey(olc::S).bHeld) { Player->Coords.y += static_cast(TileSize) * (fTime * Player->Speed); if (state != "south") state = "south"; + IsMoving = true; } if (engine->GetKey(olc::D).bHeld) { Player->Coords.x += static_cast(TileSize) * (fTime * Player->Speed); if (state != "east") state = "east"; + IsMoving = true; } if (engine->GetKey(olc::W).bHeld && engine->GetKey(olc::A).bHeld) @@ -327,7 +362,6 @@ void Dungeon::Input(olc::PixelGameEngine* engine, float fTime) Player->Coords.x += static_cast(TileSize) * (fTime * (Player->Speed / 3.0f)); if (state != "west") state = "west"; - } if (engine->GetKey(olc::W).bHeld && engine->GetKey(olc::D).bHeld) { @@ -352,8 +386,22 @@ void Dungeon::Input(olc::PixelGameEngine* engine, float fTime) state = "west"; } + if (!WasMoving && IsMoving) + { + SoundFootsteps.setPlayingOffset(sf::seconds(0.05f)); + SoundFootsteps.play(); + } + if (WasMoving && !IsMoving) + { + SoundFootsteps.stop(); + } + WasMoving = IsMoving; + if (oldCoords == Player->Coords) + { state = "idle"; + SoundFootsteps.pause(); + } if (state != lastState) Player->Animator->SetState(state); lastState = state; @@ -427,6 +475,31 @@ void Dungeon::Input(olc::PixelGameEngine* engine, float fTime) void Dungeon::Update(olc::PixelGameEngine* engine, float fTime) { ActiveCamera->Update(fTime); + + if (!HasBegun) return; + + // spawn enemies + if (Enemies.size() == 0)// rand() % 1000 < 1) + { + Enemy* enemy = new Enemy(); + enemy->Type = EEntity::Type::Enemy; + enemy->Renderable = EnemyRenderable; + enemy->Animator = EnemyAnimator; + enemy->Coords = { Player->Coords.x + static_cast((rand() % 100) - 50 ), Player->Coords.y + static_cast((rand() % 100) - 50) }; + + enemy->HitBox = new Collider{ 0, 0, 28, 36 }; + + Enemies.push_back(enemy); + } + + olc::vf2d desiredLocation = Player->Coords; + for (auto enemy : Enemies) + { + enemy->Velocity = static_cast(TileSize) * (fTime * (Player->Speed / 3.0f) * olc::vf2d(desiredLocation - enemy->Coords).norm()); + + enemy->Coords += enemy->Velocity; + } + } olc::Pixel pixelMultiply(const int x, const int y, const olc::Pixel& pSource, const olc::Pixel& pDest) @@ -447,7 +520,7 @@ void Dungeon::Draw(olc::PixelGameEngine* engine, float fTime) // Entities are always (tilesize / 3) * 2 // Dungeon Layer - engine->SetDrawTarget(3); + engine->SetDrawTarget(4); engine->Clear({38, 36, 40}); engine->SetPixelMode(olc::Pixel::ALPHA); @@ -456,25 +529,67 @@ void Dungeon::Draw(olc::PixelGameEngine* engine, float fTime) engine->DrawPartialDecal({ static_cast((tile.first.x * TileSize) - ActiveCamera->Coords.x), static_cast((tile.first.y * TileSize) - ActiveCamera->Coords.y) }, { static_cast(TileSize), static_cast(TileSize) }, TileSet->Decal(), TileSetDictionary->Dictionary[tile.second->Type], { 16, 16 }); - // Entity Layer - engine->SetDrawTarget(2); + engine->SetDrawTarget(3); engine->Clear(olc::BLANK); // Draw character Player->Animator->Draw(fTime, {Player->Coords.x - ActiveCamera->Coords.x, Player->Coords.y - ActiveCamera->Coords.y}); + for (int i = 0; i < Enemies.size(); i++) + { + _Logger.Debug(i); + Enemies[i]->Animator->SetState("idle"); + Enemies[i]->Animator->Draw(fTime, {Enemies[i]->Coords.x - ActiveCamera->Coords.x, Enemies[i]->Coords.y - ActiveCamera->Coords.y}); + } + // Lighting layers - engine->SetDrawTarget(1); + engine->SetDrawTarget(2); engine->Clear(olc::BLANK); + static bool WasFireLit = false; + static bool HasFireLit = false; + static float FireAccumilator = 0.0f; + + if (engine->GetKey(olc::F).bPressed) IsFireLit = true; + + if (!IsLightOn && !HasFireLit) + { + engine->FillRectDecal({0.0f, 0.0f}, {static_cast(engine->ScreenWidth()), static_cast(engine->ScreenHeight())}, olc::Pixel(0,0,0)); + } + + if (!IsFireLit) return; + + // Wait for fire to get going to render + if (WasFireLit != IsFireLit) + { + SoundFireLighting.setPlayingOffset(sf::seconds(0.3f)); + SoundFireLighting.play(); + } + WasFireLit = true; + static bool LastPlayFire = false; + static bool PlayFire = false; + FireAccumilator += fTime; + if (FireAccumilator > 1.4f) + PlayFire = true; + if (FireAccumilator < 1.4f) + return; + if (LastPlayFire != PlayFire) + { + SoundFire.play(); + LastPlayFire = true; + HasFireLit = true; + } + + HasBegun = true; + static std::function fPixelMultiply = pixelMultiply; // loads to make it more chaotic - float lightScale = 1.4f + GetNextPerlin(); GetNextPerlin(); GetNextPerlin(); GetNextPerlin(); GetNextPerlin(); + float lightScale = 1.2f + GetNextPerlin(); GetNextPerlin(); GetNextPerlin(); GetNextPerlin(); GetNextPerlin(); - float lightX = static_cast(Player->Coords.x - ActiveCamera->Coords.x) - ((FireOverlay->Sprite()->width * lightScale) / 2.0f); - float lightY = static_cast(Player->Coords.y - ActiveCamera->Coords.y) - ((FireOverlay->Sprite()->height * lightScale) / 2.0f); + float lightX = static_cast(Player->Coords.x - ActiveCamera->Coords.x) - ((FireOverlay->Sprite()->width * lightScale) / 2.0f) + static_cast(Player->HitBox->w) / 2.0f; + float lightY = static_cast(Player->Coords.y - ActiveCamera->Coords.y) - ((FireOverlay->Sprite()->height * lightScale) / 2.0f) + static_cast(Player->HitBox->h) / 2.0f; float lightLeft = lightX + 1.0f; float lightRight = lightX + FireOverlay->Sprite()->width * lightScale - 1.0f; @@ -511,10 +626,12 @@ Dungeon::~Dungeon() delete TileSet; for (std::pair tile : DungeonTiles) delete tile.second; - for (std::pair entity : Entities) - delete entity.second; - for (std::pair entity : FixedItems) - delete entity.second; + + for (auto enemy : Enemies) + { + delete enemy->HitBox; + delete enemy; + } free(perlinSeed); free(perlinOutput); diff --git a/The Great Machine/Dungeon.hpp b/The Great Machine/Dungeon.hpp index 10d06fa..08c3b84 100644 --- a/The Great Machine/Dungeon.hpp +++ b/The Great Machine/Dungeon.hpp @@ -2,8 +2,11 @@ #define GREATMACHINE_DUNGEON_H_ #include +#include +#include #include "olcPixelGameEngine.hpp" +#include "olcPGEX_AnimatedSprite.hpp" #include "Logger.hpp" @@ -11,6 +14,7 @@ class Camera; class Tile; class Entity; +class Enemy; class Playable; class FixedItem; class TileDictionary; @@ -22,27 +26,42 @@ class Dungeon Dungeon(); void Generate(); - void SpawnEntity(Entity* entity); void Input(olc::PixelGameEngine* engine, float fTime); void Update(olc::PixelGameEngine* engine, float fTime); void Draw(olc::PixelGameEngine* engine, float fTime); + bool HasBegun = false; + Playable* Player; Camera* ActiveCamera; - int TileSize = 64; + olc::Renderable* EnemyRenderable; + olc::AnimatedSprite* EnemyAnimator; + std::vector Enemies; + + int TileSize = 64; int DungeonWidth; int DungeonHeight; std::unordered_map DungeonTiles; - std::unordered_map Entities; - std::unordered_map FixedItems; TileDictionary* TileSetDictionary; olc::Renderable* TileSet; olc::Renderable* FireOverlay; + bool IsFireLit = false; + bool IsLightOn = true; + sf::SoundBuffer SoundBufferFireLighting; + sf::Sound SoundFireLighting; + sf::SoundBuffer SoundBufferFire; + sf::Sound SoundFire; + + sf::SoundBuffer SoundBufferAmbient; + sf::Sound SoundAmbient; + sf::SoundBuffer SoundBufferFootsteps; + sf::Sound SoundFootsteps; + ~Dungeon(); private: diff --git a/The Great Machine/Logger.cpp b/The Great Machine/Logger.cpp index 3180291..019abaf 100644 --- a/The Great Machine/Logger.cpp +++ b/The Great Machine/Logger.cpp @@ -21,13 +21,13 @@ constexpr const char* magic(ELogType::Type e) { switch (e) { - default: return ""; break; - case ELogType::Type::NONE: return ""; break; - case ELogType::Type::INFO: return "INFO"; break; - case ELogType::Type::DEBUG: return "DEBUG"; break; - case ELogType::Type::WARN: return "WARN"; break; - case ELogType::Type::ERR: return "ERROR"; break; - case ELogType::Type::PANIC: return "PANIC"; break; + default: return ""; break; + case ELogType::Type::NONE: return ""; break; + case ELogType::Type::INFO: return "INFO"; break; + case ELogType::Type::DEBUG: return "DEBUG"; break; + case ELogType::Type::WARN: return "WARN"; break; + case ELogType::Type::ERR: return "ERROR"; break; + case ELogType::Type::PANIC: return "PANIC"; break; } } @@ -37,21 +37,21 @@ void OutputWorker(Logger* _Logger) { std::unique_lock lock(_Logger->_QueueLock); _Logger->_TaskEnqueued.wait(lock, [&] { return !_Logger->_LogQueue.empty(); }); - + LogEntity* entity = _Logger->_LogQueue.front(); _Logger->_LogQueue.pop(); lock.unlock(); - + // Get C Time auto t = std::time(nullptr); auto tm = *std::localtime(&t); - + std::ostringstream oss; oss << "[" << std::put_time(&tm, "%d-%m-%Y %H:%M:%S") << "] "; - + while (_Logger->_IsLogging) {} _Logger->_IsLogging = true; - + if (entity->Type == ELogType::NONE) { oss << entity->Message; @@ -61,41 +61,41 @@ void OutputWorker(Logger* _Logger) delete entity; continue; } - + oss << "["; std::cout << oss.str(); - + switch (entity->Type) { - case ELogType::INFO: + case ELogType::INFO: Colour::ConsoleColour(EConsoleColour::FG_GREEN); break; - case ELogType::DEBUG: + case ELogType::DEBUG: Colour::ConsoleColour(EConsoleColour::FG_BLUE); break; - case ELogType::WARN: + case ELogType::WARN: Colour::ConsoleColour(EConsoleColour::FG_YELLOW); break; - case ELogType::ERR: + case ELogType::ERR: Colour::ConsoleColour(EConsoleColour::FG_LIGHT_RED); break; - case ELogType::PANIC: + case ELogType::PANIC: Colour::ConsoleColour(EConsoleColour::FG_RED); break; } - + std::cout << magic(entity->Type); Colour::ResetColour(); std::cout << "] " << entity->Message << std::endl; - + _Logger->_IsLogging = false; - + if (_Logger->_HasFileHandle) _Logger->_FileOutput << oss.str() << magic(entity->Type) << "] " << entity->Message << std::endl; - + // TODO: This won't exit, i need it to exit the main thread //if (entity->Type == ELogType::PANIC) delete entity; exit(0); - + delete entity; } } @@ -117,10 +117,10 @@ void Logger::InitializeLoggingThread() Logger::~Logger() { // Signal to the thread that its time to stop - + _IsRunning = false; _OutputWorker->join(); - + if (_OutputWorker != nullptr) delete _OutputWorker; } diff --git a/The Great Machine/Logger.hpp b/The Great Machine/Logger.hpp index 2d4ddb6..45a8cef 100644 --- a/The Great Machine/Logger.hpp +++ b/The Great Machine/Logger.hpp @@ -257,6 +257,7 @@ class Logger public: std::atomic _IsRunning = false; + std::atomic _Terminate = false; std::condition_variable _TaskEnqueued; std::queue _LogQueue; diff --git a/The Great Machine/The Great Machine.vcxproj b/The Great Machine/The Great Machine.vcxproj index 3eb96a7..bcb929c 100644 --- a/The Great Machine/The Great Machine.vcxproj +++ b/The Great Machine/The Great Machine.vcxproj @@ -81,6 +81,7 @@ false + $(LibraryPath) @@ -116,11 +117,14 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpplatest + ;C:\dev\SFML\include Console true + C:\dev\SFML\lib;%(AdditionalLibraryDirectories) + sfml-main.lib;sfml-audio.lib;sfml-system.lib @@ -132,12 +136,15 @@ NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true stdcpplatest + C:\dev\SFML\include;%(AdditionalIncludeDirectories);C:\dev\SFML\include Console true true true + sfml-main.lib;sfml-audio.lib;sfml-system.lib + C:\dev\SFML\lib;%(AdditionalLibraryDirectories) diff --git a/The Great Machine/The Great Machine.vcxproj.user b/The Great Machine/The Great Machine.vcxproj.user index 88a5509..d8f032d 100644 --- a/The Great Machine/The Great Machine.vcxproj.user +++ b/The Great Machine/The Great Machine.vcxproj.user @@ -1,4 +1,11 @@  - + + $(ProjectDir)/../ + WindowsLocalDebugger + + + $(ProjectDir)/../ + WindowsLocalDebugger + \ No newline at end of file diff --git a/The Great Machine/Things.hpp b/The Great Machine/Things.hpp index fbf1499..07e3d5e 100644 --- a/The Great Machine/Things.hpp +++ b/The Great Machine/Things.hpp @@ -129,6 +129,12 @@ class Playable : public Entity std::array Inventory; }; +class Enemy : public Entity +{ + public: + olc::vf2d Velocity = { 0.0f, 0.0f }; +}; + class TileDictionary { diff --git a/The Great Machine/main.cpp b/The Great Machine/main.cpp index be0f8f7..ce61ecc 100644 --- a/The Great Machine/main.cpp +++ b/The Great Machine/main.cpp @@ -29,67 +29,125 @@ class Game : public olc::PixelGameEngine for (int i = 0; i < 5; i++) CreateLayer(); - return true; + SetDrawTarget(uint8_t(0)); + Clear(olc::BLANK); + + return true; } void DisplayTitle(float fTime) { - if (m_TimeAccumilator > 2.0f) - { - m_DeltaFade -= fTime * 200.0f; - if (m_DeltaFade < 0.1f) m_DeltaFade = 0.0f; - } - DrawString((ScreenWidth() / 2) - (7 * 7) * (std::string("The Great Machine").length() / 2), ScreenHeight() / 2, "The Great Machine", olc::Pixel(255, 255, 255, static_cast(m_DeltaFade)), 6); - DrawString(5, ScreenHeight() - 15, "Powered by the OLC Pixel Game Engine", olc::Pixel(255, 255, 255, static_cast(m_DeltaFade))); - DrawString(ScreenWidth() - (8 * (std::string("Copyright Benjamin Kyd 2020").length())) - 5, ScreenHeight() - 15, "Copyright Benjamin Kyd 2020", olc::Pixel(255, 255, 255, static_cast(m_DeltaFade))); + DrawString((ScreenWidth() / 2) - (7 * 7) * (std::string("The Great Machine").length() / 2), ScreenHeight() / 2, "The Great Machine", olc::Pixel(255, 255, 255, static_cast(_DeltaFade)), 6); + DrawString(5, ScreenHeight() - 15, "Powered by the OLC Pixel Game Engine", olc::Pixel(255, 255, 255, static_cast(_DeltaFade))); + DrawString(ScreenWidth() - (8 * (std::string("Copyright Benjamin Kyd 2020").length())) - 5, ScreenHeight() - 15, "Copyright Benjamin Kyd 2020", olc::Pixel(255, 255, 255, static_cast(_DeltaFade))); } bool OnUserUpdate(float fTime) override { - m_TimeAccumilator += fTime; + _TimeAccumilator += fTime; Clear({38, 36, 40}); - // _Logger.Debug(m_TimeAccumilator); - //if (m_TimeAccumilator < 4.0f) - //{ - //DisplayTitle(fTime); - //return true; - //} + SetDrawTarget(uint8_t(0)); + Clear(olc::BLANK); + goto bruh; + + if (_TimeAccumilator < 6.0f) + { + Clear({38, 36, 40}); + if (_TimeAccumilator > 4.0f) + { + _DeltaFade -= fTime * 200.0f; + if (_DeltaFade < 0.1f) _DeltaFade = 0.0f; + } + DisplayTitle(fTime); + return true; + } + + + static bool IsFlicker = false; + if (_TimeAccumilator > 10.0f && _TimeAccumilator < 27.0f) + { + if (rand() % 60 < 1) + IsFlicker = true; + if (rand() % 20 < 1) + IsFlicker = false; + + if (IsFlicker) + _Dungeon->IsLightOn = true; + else + _Dungeon->IsLightOn = false; + + if (_TimeAccumilator > 13.0f) + { + _Dungeon->IsLightOn = false; + + if (_TimeAccumilator > 26.0f) + { + _DeltaFade1 -= fTime * 200.0f; + if (_DeltaFade1 < 0.1f) _DeltaFade1 = 0.0f; + } + + SetPixelMode(olc::Pixel::ALPHA); + if (_TimeAccumilator > 16.0f) + DrawString((ScreenWidth() / 2) - (7 * 3) * (std::string("the machine has done nothing for me").length() / 2), 40, "the machine has done nothing for me", olc::Pixel(255, 255, 255, static_cast(_DeltaFade1)), 3); + if (_TimeAccumilator > 20.0f) + DrawString((ScreenWidth() / 2) - (7 * 3) * (std::string("the machine has left me with nothing").length() / 2), 120, "the machine has left me with nothing", olc::Pixel(255, 255, 255, static_cast(_DeltaFade1)), 3); + if (_TimeAccumilator > 23.0f) + DrawString((ScreenWidth() / 2) - (7 * 5) * (std::string("i am nothing").length() / 2), 300, "i am nothing", olc::Pixel(255, 255, 255, static_cast(_DeltaFade1)), 5); + } + } + + if (_TimeAccumilator > 26.0f) + { + _Dungeon->IsFireLit = true; + } + + bruh: _Dungeon->Input(this, fTime); - _Dungeon->Update(this, fTime); + _Dungeon->Update(this, fTime); - _Dungeon->Draw(this, fTime); + _Dungeon->Draw(this, fTime); for (int i = 0; i < 5; i++) EnableLayer(i, true); - return true; + return true; } + bool OnUserDestroy() override + { + delete _Dungeon; + return true; + } + private: - long float m_TimeAccumilator = 0; - - float m_DeltaFade = 255.0f; + long float _TimeAccumilator = 0.0f; + float _DeltaFade = 255.0f; + float _DeltaFade1 = 255.0f; }; +#include int main() { Logger& _Logger = Logger::getInstance(); _Logger.InitializeFileLogging("./logs.log"); _Logger.InitializeLoggingThread(); + _Logger.Debug("Initializing"); - Game _Game; - _Game.Construct(1280, 720, 1, 1, false, false); - _Logger.Info("Game Constructed"); - - if (!_Game.Start()) - { - _Logger.Panic("PGE Cannot start"); - } + Game _Game; + _Game.Construct(1280, 720, 1, 1, false, false); + _Logger.Info("Game Constructed"); + + if (!_Game.Start()) + { + _Logger.Panic("PGE Cannot start"); + } + + _Logger.~Logger(); } diff --git a/The Great Machine/res/dungeon_pre.png b/The Great Machine/res/dungeon_pre.png deleted file mode 100644 index c6d8d52..0000000 Binary files a/The Great Machine/res/dungeon_pre.png and /dev/null differ diff --git a/The Great Machine/res/dungeon_tileset.png b/The Great Machine/res/dungeon_tileset.png deleted file mode 100644 index 0350d1b..0000000 Binary files a/The Great Machine/res/dungeon_tileset.png and /dev/null differ diff --git a/The Great Machine/res/player.png b/The Great Machine/res/player.png deleted file mode 100644 index 6954bb9..0000000 Binary files a/The Great Machine/res/player.png and /dev/null differ diff --git a/The Great Machine/res/torch.png b/The Great Machine/res/torch.png deleted file mode 100644 index 4bb2d78..0000000 Binary files a/The Great Machine/res/torch.png and /dev/null differ diff --git a/res/ambient.ogg b/res/ambient.ogg new file mode 100644 index 0000000..62e5ed5 Binary files /dev/null and b/res/ambient.ogg differ diff --git a/res/fire.wav b/res/fire.wav new file mode 100644 index 0000000..3588cd4 Binary files /dev/null and b/res/fire.wav differ diff --git a/res/fire_start.wav b/res/fire_start.wav new file mode 100644 index 0000000..139ec58 Binary files /dev/null and b/res/fire_start.wav differ diff --git a/res/run.ogg b/res/run.ogg new file mode 100644 index 0000000..d5fdace Binary files /dev/null and b/res/run.ogg differ diff --git a/sfml-audio-2.dll b/sfml-audio-2.dll new file mode 100644 index 0000000..0fb3aff Binary files /dev/null and b/sfml-audio-2.dll differ diff --git a/sfml-system-2.dll b/sfml-system-2.dll new file mode 100644 index 0000000..2e6f28f Binary files /dev/null and b/sfml-system-2.dll differ