?
This commit is contained in:
@@ -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<int>(static_cast<float>(TileSize) * (fTime * 10.0f));
|
||||
if (engine->GetKey(olc::A).bHeld)
|
||||
Player->Coords.x -= 1000 * fTime;
|
||||
Player->Coords.x -= static_cast<int>(static_cast<float>(TileSize) * (fTime * 10.0f));
|
||||
if (engine->GetKey(olc::S).bHeld)
|
||||
Player->Coords.y += 1000 * fTime;
|
||||
Player->Coords.y += static_cast<int>(static_cast<float>(TileSize) * (fTime * 10.0f));
|
||||
if (engine->GetKey(olc::D).bHeld)
|
||||
Player->Coords.x += 1000 * fTime;
|
||||
Player->Coords.x += static_cast<int>(static_cast<float>(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<olc::vi2d, Tile*> tile : DungeonTiles)
|
||||
{
|
||||
// TODO: Perform culling
|
||||
engine->DrawPartialDecal({ static_cast<float>((tile.first.x * 64) - ActiveCamera->Coords.x), static_cast<float>((tile.first.y * 64) - ActiveCamera->Coords.y) },
|
||||
{ 64, 64 }, TileSet->Decal(), TileSetDictionary->Dictionary[tile.second->Type], { 16, 16 });
|
||||
|
||||
engine->DrawPartialDecal({ static_cast<float>((tile.first.x * TileSize) - ActiveCamera->Coords.x), static_cast<float>((tile.first.y * TileSize) - ActiveCamera->Coords.y) },
|
||||
{ static_cast<float>(TileSize), static_cast<float>(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<float>(Player->Coords.x - ActiveCamera->Coords.x), static_cast<float>(Player->Coords.y - ActiveCamera->Coords.y) },
|
||||
{ 64, 64 }, TileSet->Decal(), { 143, 130 }, { 16, 16 });
|
||||
{ (static_cast<float>(TileSize) / 3.0f) * 2.0f, (static_cast<float>(TileSize) / 3.0f) * 2.0f }, TileSet->Decal(), { 143, 130 }, { 16, 16 });
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ public:
|
||||
Playable* Player;
|
||||
Camera* ActiveCamera;
|
||||
|
||||
int TileSize = 16;
|
||||
|
||||
int DungeonWidth;
|
||||
int DungeonHeight;
|
||||
std::unordered_map<olc::vi2d, Tile*> DungeonTiles;
|
||||
@@ -40,7 +42,7 @@ public:
|
||||
TileDictionary* TileSetDictionary;
|
||||
olc::Renderable* TileSet;
|
||||
|
||||
// olc::Renderable* DungeonRenderTarget;
|
||||
olc::Renderable* DungeonRenderTarget;
|
||||
|
||||
~Dungeon();
|
||||
|
||||
|
||||
@@ -142,6 +142,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Camera.cpp" />
|
||||
<ClCompile Include="Collisions.cpp" />
|
||||
<ClCompile Include="Dungeon.cpp" />
|
||||
<ClCompile Include="Logger.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
@@ -149,6 +150,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Camera.hpp" />
|
||||
<ClInclude Include="Collisions.hpp" />
|
||||
<ClInclude Include="Dungeon.hpp" />
|
||||
<ClInclude Include="Logger.hpp" />
|
||||
<ClInclude Include="olcPixelGameEngine.hpp" />
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
<ClCompile Include="Camera.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Collisions.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="olcPixelGameEngine.hpp">
|
||||
@@ -47,5 +50,8 @@
|
||||
<ClInclude Include="Camera.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Collisions.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user