diff --git a/The Great Machine/Camera.cpp b/The Great Machine/Camera.cpp new file mode 100644 index 0000000..33b791c --- /dev/null +++ b/The Great Machine/Camera.cpp @@ -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; +} diff --git a/The Great Machine/Camera.hpp b/The Great Machine/Camera.hpp index 9679798..36f300d 100644 --- a/The Great Machine/Camera.hpp +++ b/The Great Machine/Camera.hpp @@ -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 diff --git a/The Great Machine/Dungeon.hpp b/The Great Machine/Dungeon.hpp index 14ad5af..1aaf328 100644 --- a/The Great Machine/Dungeon.hpp +++ b/The Great Machine/Dungeon.hpp @@ -1,13 +1,29 @@ #ifndef GREATMACHINE_DUNGEON_H_ #define GREATMACHINE_DUNGEON_H_ +#include + +#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 Dungeon; + std::unordered_map Entities; + std::unordered_map FixedItems; }; #endif diff --git a/The Great Machine/The Great Machine.vcxproj b/The Great Machine/The Great Machine.vcxproj index 945c31b..cac23d2 100644 --- a/The Great Machine/The Great Machine.vcxproj +++ b/The Great Machine/The Great Machine.vcxproj @@ -141,12 +141,14 @@ + + diff --git a/The Great Machine/The Great Machine.vcxproj.filters b/The Great Machine/The Great Machine.vcxproj.filters index 357681e..30b3383 100644 --- a/The Great Machine/The Great Machine.vcxproj.filters +++ b/The Great Machine/The Great Machine.vcxproj.filters @@ -27,6 +27,9 @@ Source Files + + Source Files + @@ -41,5 +44,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/The Great Machine/Things.cpp b/The Great Machine/Things.cpp index 58a2a9d..f769da9 100644 --- a/The Great Machine/Things.cpp +++ b/The Great Machine/Things.cpp @@ -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 }); } diff --git a/The Great Machine/Things.hpp b/The Great Machine/Things.hpp index 55139ef..641e955 100644 --- a/The Great Machine/Things.hpp +++ b/The Great Machine/Things.hpp @@ -2,9 +2,12 @@ #define GREATMACHINE_THINGS_H_ #include +#include #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 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