boilerplate, boiler plates everywhere
This commit is contained in:
20
The Great Machine/Camera.cpp
Normal file
20
The Great Machine/Camera.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#include "Camera.hpp"
|
||||||
|
|
||||||
|
#include "Things.hpp"
|
||||||
|
|
||||||
|
void Camera::Update(float fTime)
|
||||||
|
{
|
||||||
|
if (_Track == nullptr) return;
|
||||||
|
Coords.x = _Track->Coords.x;
|
||||||
|
Coords.y = _Track->Coords.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera::Input(olc::PixelGameEngine* engine)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera::TrackEntity(Entity* entity)
|
||||||
|
{
|
||||||
|
_Track = entity;
|
||||||
|
}
|
||||||
@@ -1,6 +1,26 @@
|
|||||||
#ifndef GREATMACHINE_CAMERA_H_
|
#ifndef GREATMACHINE_CAMERA_H_
|
||||||
#define GREATMACHINE_CAMERA_H_
|
#define GREATMACHINE_CAMERA_H_
|
||||||
|
|
||||||
|
#include "olcPixelGameEngine.hpp"
|
||||||
|
|
||||||
|
class Entity;
|
||||||
|
|
||||||
|
class Camera
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
olc::vd2d Coords;
|
||||||
|
olc::vd2d ViewPort;
|
||||||
|
|
||||||
|
void Update(float fTime);
|
||||||
|
|
||||||
|
void Input(olc::PixelGameEngine* engine);
|
||||||
|
|
||||||
|
void TrackEntity(Entity* e);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
Entity* _Track = nullptr;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,13 +1,29 @@
|
|||||||
#ifndef GREATMACHINE_DUNGEON_H_
|
#ifndef GREATMACHINE_DUNGEON_H_
|
||||||
#define GREATMACHINE_DUNGEON_H_
|
#define GREATMACHINE_DUNGEON_H_
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "olcPixelGameEngine.hpp"
|
||||||
|
|
||||||
|
class Tile;
|
||||||
|
class Entity;
|
||||||
|
class FixedItem;
|
||||||
|
|
||||||
|
// Single level dungeon, no need for fancy levels
|
||||||
class Dungeon
|
class Dungeon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
void Generate();
|
||||||
|
void SpawnEntity();
|
||||||
|
|
||||||
|
void Update(float fTime);
|
||||||
|
void Draw(olc::PixelGameEngine* engine);
|
||||||
|
|
||||||
|
|
||||||
|
std::unordered_map<olc::vd2d, Tile*> Dungeon;
|
||||||
|
std::unordered_map<olc::vd2d, Entity*> Entities;
|
||||||
|
std::unordered_map<olc::vd2d, FixedItem*> FixedItems;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -141,12 +141,14 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Camera.cpp" />
|
||||||
<ClCompile Include="Dungeon.cpp" />
|
<ClCompile Include="Dungeon.cpp" />
|
||||||
<ClCompile Include="Logger.cpp" />
|
<ClCompile Include="Logger.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="Things.cpp" />
|
<ClCompile Include="Things.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Camera.hpp" />
|
||||||
<ClInclude Include="Dungeon.hpp" />
|
<ClInclude Include="Dungeon.hpp" />
|
||||||
<ClInclude Include="Logger.hpp" />
|
<ClInclude Include="Logger.hpp" />
|
||||||
<ClInclude Include="olcPixelGameEngine.hpp" />
|
<ClInclude Include="olcPixelGameEngine.hpp" />
|
||||||
|
|||||||
@@ -27,6 +27,9 @@
|
|||||||
<ClCompile Include="Things.cpp">
|
<ClCompile Include="Things.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Camera.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="olcPixelGameEngine.hpp">
|
<ClInclude Include="olcPixelGameEngine.hpp">
|
||||||
@@ -41,5 +44,8 @@
|
|||||||
<ClInclude Include="Things.hpp">
|
<ClInclude Include="Things.hpp">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Camera.hpp">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
#include "Things.hpp"
|
#include "Things.hpp"
|
||||||
|
|
||||||
|
#include "Camera.hpp"
|
||||||
|
|
||||||
void Tile::Update(float fTime)
|
void Tile::Update(float fTime)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tile::Draw(olc::PixelGameEngine* engine, )
|
void Tile::Draw(olc::PixelGameEngine* engine, Camera* camera)
|
||||||
{
|
{
|
||||||
engine->DrawPartialSprite()
|
engine->DrawPartialSprite(
|
||||||
|
{ Coords.x + camera->Coords.x, Coords.y + camera->Coords.y },
|
||||||
|
SpriteMap, SpriteTextureMask, { 16, 16 });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,12 @@
|
|||||||
#define GREATMACHINE_THINGS_H_
|
#define GREATMACHINE_THINGS_H_
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "olcPixelGameEngine.hpp"
|
#include "olcPixelGameEngine.hpp"
|
||||||
|
|
||||||
|
class Camera;
|
||||||
|
|
||||||
namespace ETile
|
namespace ETile
|
||||||
{
|
{
|
||||||
enum Type
|
enum Type
|
||||||
@@ -64,10 +67,18 @@ public:
|
|||||||
|
|
||||||
class FixedItem : public Entity
|
class FixedItem : public Entity
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
EEntity::EItem::FixedItem Item;
|
EEntity::EItem::FixedItem Item;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Playable : public Entity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::array<Item*, 6> Inventory;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class Tile
|
class Tile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -79,7 +90,7 @@ public:
|
|||||||
olc::Sprite* SpriteMap;
|
olc::Sprite* SpriteMap;
|
||||||
|
|
||||||
virtual void Update(float fTime);
|
virtual void Update(float fTime);
|
||||||
void Draw(olc::PixelGameEngine* engine);
|
void Draw(olc::PixelGameEngine* engine, Camera* camera);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user