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_
|
||||
#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
|
||||
|
||||
@@ -1,13 +1,29 @@
|
||||
#ifndef 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
|
||||
{
|
||||
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
|
||||
|
||||
@@ -141,12 +141,14 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Camera.cpp" />
|
||||
<ClCompile Include="Dungeon.cpp" />
|
||||
<ClCompile Include="Logger.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="Things.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Camera.hpp" />
|
||||
<ClInclude Include="Dungeon.hpp" />
|
||||
<ClInclude Include="Logger.hpp" />
|
||||
<ClInclude Include="olcPixelGameEngine.hpp" />
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
<ClCompile Include="Things.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Camera.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="olcPixelGameEngine.hpp">
|
||||
@@ -41,5 +44,8 @@
|
||||
<ClInclude Include="Things.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Camera.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,11 +1,15 @@
|
||||
#include "Things.hpp"
|
||||
|
||||
#include "Camera.hpp"
|
||||
|
||||
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_
|
||||
|
||||
#include <optional>
|
||||
#include <array>
|
||||
|
||||
#include "olcPixelGameEngine.hpp"
|
||||
|
||||
class Camera;
|
||||
|
||||
namespace ETile
|
||||
{
|
||||
enum Type
|
||||
@@ -64,10 +67,18 @@ public:
|
||||
|
||||
class FixedItem : public Entity
|
||||
{
|
||||
public:
|
||||
EEntity::EItem::FixedItem Item;
|
||||
};
|
||||
|
||||
|
||||
class Playable : public Entity
|
||||
{
|
||||
public:
|
||||
std::array<Item*, 6> Inventory;
|
||||
};
|
||||
|
||||
|
||||
class Tile
|
||||
{
|
||||
public:
|
||||
@@ -79,7 +90,7 @@ public:
|
||||
olc::Sprite* SpriteMap;
|
||||
|
||||
virtual void Update(float fTime);
|
||||
void Draw(olc::PixelGameEngine* engine);
|
||||
void Draw(olc::PixelGameEngine* engine, Camera* camera);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user