From d3e3477cd937c046decccda13e8518a0f5ae429d Mon Sep 17 00:00:00 2001 From: Ben Kyd Date: Thu, 3 Sep 2020 15:17:21 +0000 Subject: [PATCH] ? --- The Great Machine/Dungeon.cpp | 24 ++++++++++++------- The Great Machine/Dungeon.hpp | 4 +++- The Great Machine/The Great Machine.vcxproj | 2 ++ .../The Great Machine.vcxproj.filters | 6 +++++ The Great Machine/main.cpp | 10 ++++---- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/The Great Machine/Dungeon.cpp b/The Great Machine/Dungeon.cpp index 7077850..a5a3f46 100644 --- a/The Great Machine/Dungeon.cpp +++ b/The Great Machine/Dungeon.cpp @@ -174,8 +174,9 @@ void Dungeon::Generate() DungeonTiles[t->Coords] = t; } - // DungeonRenderTarget = new olc::Renderable(); - // DungeonRenderTarget->Create(DungeonWidth * 32, DungeonHeight * 32); + DungeonRenderTarget = new olc::Renderable(); + //DungeonRenderTarget->Create(DungeonWidth * TileSize, DungeonHeight * TileSize); + //DungeonRenderTarget->Create(200, 200); } void Dungeon::SpawnEntity(Entity* entity) @@ -186,13 +187,13 @@ void Dungeon::SpawnEntity(Entity* entity) void Dungeon::Input(olc::PixelGameEngine* engine, float fTime) { if (engine->GetKey(olc::W).bHeld) - Player->Coords.y -= 1000 * fTime; + Player->Coords.y -= static_cast(static_cast(TileSize) * (fTime * 10.0f)); if (engine->GetKey(olc::A).bHeld) - Player->Coords.x -= 1000 * fTime; + Player->Coords.x -= static_cast(static_cast(TileSize) * (fTime * 10.0f)); if (engine->GetKey(olc::S).bHeld) - Player->Coords.y += 1000 * fTime; + Player->Coords.y += static_cast(static_cast(TileSize) * (fTime * 10.0f)); if (engine->GetKey(olc::D).bHeld) - Player->Coords.x += 1000 * fTime; + Player->Coords.x += static_cast(static_cast(TileSize) * (fTime * 10.0f)); } void Dungeon::Update(float fTime) @@ -202,17 +203,22 @@ void Dungeon::Update(float fTime) void Dungeon::Draw(olc::PixelGameEngine* engine) { + //int + engine->SetDrawTarget(DungeonRenderTarget->Sprite()); for (std::pair tile : DungeonTiles) { // TODO: Perform culling - engine->DrawPartialDecal({ static_cast((tile.first.x * 64) - ActiveCamera->Coords.x), static_cast((tile.first.y * 64) - ActiveCamera->Coords.y) }, - { 64, 64 }, TileSet->Decal(), TileSetDictionary->Dictionary[tile.second->Type], { 16, 16 }); + + 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 }); } + engine->SetDrawTarget(1); + engine->DrawSprite({ 0, 0 }, DungeonRenderTarget->Sprite()); // Draw character engine->DrawPartialDecal({ static_cast(Player->Coords.x - ActiveCamera->Coords.x), static_cast(Player->Coords.y - ActiveCamera->Coords.y) }, - { 64, 64 }, TileSet->Decal(), { 143, 130 }, { 16, 16 }); + { (static_cast(TileSize) / 3.0f) * 2.0f, (static_cast(TileSize) / 3.0f) * 2.0f }, TileSet->Decal(), { 143, 130 }, { 16, 16 }); } diff --git a/The Great Machine/Dungeon.hpp b/The Great Machine/Dungeon.hpp index ee9069f..4723ef7 100644 --- a/The Great Machine/Dungeon.hpp +++ b/The Great Machine/Dungeon.hpp @@ -31,6 +31,8 @@ public: Playable* Player; Camera* ActiveCamera; + int TileSize = 16; + int DungeonWidth; int DungeonHeight; std::unordered_map DungeonTiles; @@ -40,7 +42,7 @@ public: TileDictionary* TileSetDictionary; olc::Renderable* TileSet; - // olc::Renderable* DungeonRenderTarget; + olc::Renderable* DungeonRenderTarget; ~Dungeon(); diff --git a/The Great Machine/The Great Machine.vcxproj b/The Great Machine/The Great Machine.vcxproj index cac23d2..141ce50 100644 --- a/The Great Machine/The Great Machine.vcxproj +++ b/The Great Machine/The Great Machine.vcxproj @@ -142,6 +142,7 @@ + @@ -149,6 +150,7 @@ + diff --git a/The Great Machine/The Great Machine.vcxproj.filters b/The Great Machine/The Great Machine.vcxproj.filters index 30b3383..7593cb7 100644 --- a/The Great Machine/The Great Machine.vcxproj.filters +++ b/The Great Machine/The Great Machine.vcxproj.filters @@ -30,6 +30,9 @@ Source Files + + Source Files + @@ -47,5 +50,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/The Great Machine/main.cpp b/The Great Machine/main.cpp index bf62510..36c8ffc 100644 --- a/The Great Machine/main.cpp +++ b/The Great Machine/main.cpp @@ -48,11 +48,11 @@ public: // _Logger.Debug(m_TimeAccumilator); - if (m_TimeAccumilator < 4.0f) - { - DisplayTitle(fTime); - return true; - } + //if (m_TimeAccumilator < 4.0f) + //{ + // DisplayTitle(fTime); + // return true; + //} _Dungeon->Input(this, fTime);