diff --git a/imgui.ini b/imgui.ini index c113d5b..34eb2fb 100644 --- a/imgui.ini +++ b/imgui.ini @@ -11,6 +11,6 @@ Pos=60,60 Size=536,286 [Window][sdfkjasbdf] -Pos=679,86 +Pos=679,85 Size=610,481 diff --git a/include/Containers/Array.h b/include/Containers/Array.h index 10a4f76..adea85d 100644 --- a/include/Containers/Array.h +++ b/include/Containers/Array.h @@ -6,12 +6,13 @@ namespace container { + using CapacityType = EntityIndex; using BoolArrayType = u8; template class Array -{ +{ public: using data_type = T; using pointer = data_type*; @@ -22,69 +23,69 @@ public: using iterator_category = std::forward_iterator_tag; public: - class Iterator + class iterator { public: - Iterator(data_type* const input) + iterator(data_type* input) : m_ptr(input) { } - Iterator& operator++() + iterator& operator++() { m_ptr++; return *this; } - Iterator operator++(int) + iterator operator++(int) { auto it = *this; m_ptr++; return it; } - Iterator& operator--() + iterator& operator--() { m_ptr--; return *this; } - Iterator operator--(int) + iterator operator--(int) { auto it = *this; m_ptr++; return it; } - reference operator[](const CapacityType index) const { return m_ptr[index]; } + reference operator[](CapacityType index) const { return m_ptr[index]; } pointer operator->() const { return m_ptr; } reference operator*() const { return *m_ptr; } - bool operator==(const Iterator& other) const { return m_ptr == other.m_ptr; } - bool operator!=(const Iterator& other) const { return m_ptr != other.m_ptr; } + bool operator==(iterator other) const { return m_ptr == other.m_ptr; } + bool operator!=(iterator other) const { return m_ptr != other.m_ptr; } private: pointer m_ptr; }; - class ConstIterator + class const_iterator { public: - ConstIterator(data_type* const input) + const_iterator(data_type* input) : m_ptr(input) { } - ConstIterator& operator++() + const_iterator& operator++() { m_ptr++; return *this; } - ConstIterator operator++(int) + const_iterator operator++(int) { auto it = *this; m_ptr++; return it; } - ConstIterator& operator--() + const_iterator& operator--() { m_ptr--; return *this; } - ConstIterator operator--(int) + const_iterator operator--(int) { auto it = *this; m_ptr++; return it; } - const_reference operator[](const CapacityType index) const { return m_ptr[index]; } + const_reference operator[](CapacityType index) const { return m_ptr[index]; } const_pointer operator->() const { return m_ptr; } const_reference operator*() const { return *m_ptr; } - bool operator==(const ConstIterator& other) const { return m_ptr == other.m_ptr; } - bool operator!=(const ConstIterator& other) const { return m_ptr != other.m_ptr; } + bool operator==(const_iterator other) const { return m_ptr == other.m_ptr; } + bool operator!=(const_iterator other) const { return m_ptr != other.m_ptr; } private: pointer m_ptr; }; public: - Array() { m_data = new T[capacity]; } + Array() { m_data = new T[capacity]{}; } ~Array() { delete[] m_data; } @@ -114,9 +115,9 @@ public: const_pointer cosntData() const { return m_data; } - reference operator[](const CapacityType index) { return m_data[index]; } + reference operator[](CapacityType index) { return m_data[index]; } - const_reference operator[](const CapacityType index) const { return m_data[index]; } + const_reference operator[](CapacityType index) const { return m_data[index]; } pointer operator->() { return m_data; } @@ -128,11 +129,11 @@ public: inline constexpr CapacityType size() const { return capacity; } - Iterator begin() { return Iterator(m_data); } - Iterator end() { return Iterator(m_data + capacity); } + iterator begin() { return iterator(m_data); } + iterator end() { return iterator(m_data + capacity); } - ConstIterator begin() const { return ConstIterator(m_data); } - ConstIterator end() const { return ConstIterator(m_data + capacity); } + const_iterator begin() const { return const_iterator(m_data); } + const_iterator end() const { return const_iterator(m_data + capacity); } private: pointer m_data; @@ -145,10 +146,9 @@ class Array { public: class reference; - class const_reference; - using data_type = BoolArrayType; using pointer = reference; - using const_pointer = const_reference; + using const_reference = bool; + using data_type = BoolArrayType; using difference_type = std::ptrdiff_t; using iterator_category = std::forward_iterator_tag; @@ -156,7 +156,7 @@ public: class reference { friend class Array; - reference(data_type* const ptr_in, const data_type mask_in) + reference(data_type* ptr_in, data_type mask_in) : m_ptr(ptr_in) , m_mask(mask_in) { @@ -167,14 +167,14 @@ public: ~reference() { } - reference(const reference&) = default; + reference(reference&) = default; operator bool () const { return !!(*m_ptr & m_mask); } - reference& operator=(const bool input) + reference& operator=(bool input) { switch ((int)input) { @@ -182,7 +182,7 @@ public: *m_ptr |= m_mask; break; case false: - *m_ptr &= m_mask; + *m_ptr &= ~m_mask; break; } return *this; @@ -203,42 +203,44 @@ public: const data_type m_mask; }; - class const_reference - { - friend class Array; - const_reference(const data_type* ptr_in, const data_type mask_in) - : m_ptr(ptr_in) - , m_mask(mask_in) - { } - public: - ~const_reference() - { } - - const_reference(const const_reference&) = delete; - - operator bool () const { return !!(*m_ptr & m_mask); } - - const_reference& operator=(bool) = delete; - - const_reference& operator=(const const_reference& other) = delete; - const_reference& operator=(const reference& other) = delete; - - private: - const data_type* const m_ptr; - const data_type m_mask; - }; + //class const_reference + //{ + // friend class Array; + // const_reference(const data_type* ptr_in, const data_type mask_in) + // : m_ptr(ptr_in) + // , m_mask(mask_in) + // { } + + //public: + // ~const_reference() + // { } + + // const_reference(const const_reference&) = delete; + + // operator bool () const { return !!(*m_ptr & m_mask); } + + // const_reference& operator=(bool) = delete; + + // const_reference& operator=(const const_reference& other) = delete; + // const_reference& operator=(const reference& other) = delete; + + //private: + // const data_type* const m_ptr; + // const data_type m_mask; + //}; - class Iterator + + class iterator { public: - Iterator(data_type* const input, const data_type index) + iterator(const data_type* input, data_type index) : m_ptr(input) , m_bitIndex(index) { } - Iterator& operator++() + iterator& operator++() { switch (m_bitIndex++) { @@ -253,7 +255,7 @@ public: } } - Iterator operator++(int) + iterator operator++(int) { auto it = *this; switch (m_bitIndex++) @@ -269,7 +271,7 @@ public: } } - Iterator& operator--() + iterator& operator--() { switch (m_bitIndex--) { @@ -284,7 +286,7 @@ public: } } - Iterator operator--(int) + iterator operator--(int) { auto it = *this; switch (m_bitIndex--) @@ -300,18 +302,22 @@ public: } } - bool operator[](const int) = delete; + reference operator[](CapacityType index) + { + return reference(m_ptr + (index / 7), m_bitIndex + (index % 8)); + } + reference operator*() const { return reference(m_ptr, 1 << m_bitIndex); } - bool operator==(const Iterator& other) const + bool operator==(const iterator& other) const { return (m_ptr == other.m_ptr) && (m_bitIndex == other.m_bitIndex); } - bool operator!=(const Iterator& other) const + bool operator!=(const iterator& other) const { return (m_ptr != other.m_ptr) || (m_bitIndex != other.m_bitIndex); } @@ -321,15 +327,15 @@ public: data_type m_bitIndex{}; }; - class ConstIterator + class const_iterator { public: - ConstIterator(const data_type* input, const data_type index) + const_iterator(const data_type* input, data_type index) : m_ptr(input) , m_bitIndex(index) { } - ConstIterator& operator++() + const_iterator& operator++() { switch (m_bitIndex++) { @@ -344,7 +350,7 @@ public: } } - ConstIterator operator++(int) + const_iterator operator++(int) { auto it = *this; switch (m_bitIndex++) @@ -360,7 +366,7 @@ public: } } - ConstIterator& operator--() + const_iterator& operator--() { switch (m_bitIndex--) { @@ -375,7 +381,7 @@ public: } } - ConstIterator operator--(int) + const_iterator operator--(int) { auto it = *this; switch (m_bitIndex--) @@ -391,15 +397,17 @@ public: } } - bool operator[](const int) = delete; + const_reference operator[](CapacityType index) const + { return (m_ptr + (index / 8)) & (1 << (index % 8)); } + const_reference operator*() const - { return const_reference(m_ptr, 1 << m_bitIndex); } + { return *m_ptr & (1 << m_bitIndex); } - bool operator==(const ConstIterator& other) const + bool operator==(const const_iterator& other) const { return (m_ptr == other.m_ptr) && (m_bitIndex == other.m_bitIndex); } - bool operator!=(const ConstIterator& other) const + bool operator!=(const const_iterator& other) const { return (m_ptr != other.m_ptr) || (m_bitIndex != other.m_bitIndex); } private: @@ -408,7 +416,7 @@ public: }; public: - Array() { m_data = new data_type[(capacity / 8) + 1]; } + Array() { m_data = new data_type[(capacity / 8) + 1]{}; } ~Array() { delete[] m_data; } @@ -433,20 +441,19 @@ public: return *this; } - - //use readAt() instead - reference operator[](const CapacityType index) + reference operator[](CapacityType index) { return reference(m_data + (index / 8), 1 << (index % 8)); } - const_reference operator[](const CapacityType index) const - { return reference(m_data + (index / 8), 1 << (index % 8)); } + const_reference operator[](CapacityType index) const + { return m_data[index / 8] & (1 << (index % 8)); } inline constexpr CapacityType size() { return capacity; } - bool readAt(const CapacityType index) const { return m_data[index / 8] & (1 << (index % 8)); } + const_reference readAt(CapacityType index) const + { return m_data[index / 8] & (1 << (index % 8)); } - void changeAt(const CapacityType index, const bool input) + void changeAt(CapacityType index, bool input) { switch ((int)input) { @@ -459,11 +466,11 @@ public: } } - Iterator begin() { return Iterator(m_data, 0); } - Iterator end() { return Iterator(m_data + (capacity / 8), capacity % 8); } + iterator begin() { return iterator(m_data, 0); } + iterator end() { return iterator(m_data + (capacity / 8), capacity % 8); } - ConstIterator begin() const { return ConstIterator(m_data, 0); } - ConstIterator end() const { return ConstIterator(m_data + (capacity / 8), capacity % 8); } + const_iterator begin() const { return const_iterator(m_data, 0); } + const_iterator end() const { return const_iterator(m_data + (capacity / 8), capacity % 8); } private: data_type* m_data; diff --git a/include/Entities/Components.h b/include/Entities/Components.h index a23b526..a5df5b6 100644 --- a/include/Entities/Components.h +++ b/include/Entities/Components.h @@ -28,11 +28,13 @@ public: class Texture : public Component { public: - sf::Texture& texture; + Texture() = default; + int texture{}; }; class BoundingBox : public Component { public: + BoundingBox() = default; sf::FloatRect bBox{}; }; \ No newline at end of file diff --git a/include/Entities/Entity.h b/include/Entities/Entity.h index cd72e9e..222c9ad 100644 --- a/include/Entities/Entity.h +++ b/include/Entities/Entity.h @@ -3,16 +3,15 @@ #include class EntityManager; -class EntityViewIterator; -class EntityViewConstIterator; +class EntityView; +class EntityMemoryPool; class Entity { -//private: public: friend class EntityManager; - friend class EntityViewIterator; - friend class EntityViewConstIterator; + friend class EntityView; + friend class EntityMemoryPool; Entity() = delete; Entity(EntityIndex); @@ -25,14 +24,11 @@ public: T& getComponent() const; template - T& getComponent(); + void addComponent(const T&); - template - void addComponent(const T&&); + size_t id() const; - EntityIndex id() const; - - EntityTag tag() const; + Tag tag() const; bool isAlive() const; diff --git a/include/Entities/EntityManager.h b/include/Entities/EntityManager.h index 3ccbec6..65a6b81 100644 --- a/include/Entities/EntityManager.h +++ b/include/Entities/EntityManager.h @@ -4,18 +4,18 @@ #include "Entities/EntityView.h" #include "utility.h" #include -#include +#include class EntityManager { public: void update(); -private: - EntityView getEntiites(EntityTag); + + EntityView getEntiites(Tag); inline Entity player(); -private: - Entity m_player{0}; - std::array m_numEntitiesByTag{}; + +private: + EntityIndex m_numEntitiesByTag[util::TAG_COUNT]; u16 m_numEntities{}; }; diff --git a/include/Entities/EntityMemoryPool.h b/include/Entities/EntityMemoryPool.h index b231951..9b5104f 100644 --- a/include/Entities/EntityMemoryPool.h +++ b/include/Entities/EntityMemoryPool.h @@ -1,50 +1,73 @@ #pragma once -#include "utility.h" #include #include #include #include -#include +#include +#include -using ComponentVectorTuple = std::tuple +class EntityManager; +class Entity; + +using ComponentsContainer = std::tuple < - std::vector, - std::vector, - std::vector + container::Array, + container::Array, + container::Array >; class EntityMemoryPool { private: - ComponentVectorTuple m_components; - std::vector m_tags; - std::vector m_aliveStates; - std::vector m_ids; + friend class EntityManager; + friend class Entity; + + ComponentsContainer m_components; + container::Array m_tags; + container::Array m_aliveStates; + container::Array m_ids; private: EntityMemoryPool(); EntityMemoryPool(const EntityMemoryPool&) = delete; -public: - static EntityMemoryPool& instance(); + static EntityMemoryPool& instance() + { + static EntityMemoryPool pool{}; + return pool; + } template - bool hasComponent(EntityIndex) const; - - template - T& getComponent(EntityIndex) const; + bool hasComponent(EntityIndex index) const + { return std::get>(m_components)[index].active; } template - T& getComponent(EntityIndex); + T& getComponent(EntityIndex index) + { + return std::get>(m_components)[index]; + } - EntityTag getTag(EntityIndex) const; + Tag getTag(EntityIndex index) const + { + return m_tags[index]; + } - bool getAlive(EntityIndex) const; + bool getAlive(EntityIndex index) const + { + return m_aliveStates[index]; + } - size_t getId(EntityIndex) const; + size_t& getId(EntityIndex index) + { + return m_ids[index]; + } - void removeEntity(EntityIndex); -}; \ No newline at end of file + void removeEntity(EntityIndex index) + { + m_aliveStates[index] = false; + return; + } +}; diff --git a/include/Entities/EntityView.h b/include/Entities/EntityView.h index ff453ea..840ab93 100644 --- a/include/Entities/EntityView.h +++ b/include/Entities/EntityView.h @@ -3,59 +3,6 @@ #include "utility.h" #include -class EntityView; - -class EntityViewIterator -{ - friend class EntityView; - - EntityViewIterator(EntityIndex); - - EntityViewIterator& operator++(); - - EntityViewIterator operator++(int); - - EntityViewIterator& operator--(); - - EntityViewIterator operator--(int); - - Entity operator*(); - - Entity operator[](int); - - bool operator==(EntityViewIterator); - bool operator!=(EntityViewIterator); - -private: - EntityIndex m_currentEntity; -}; - -class EntityViewConstIterator -{ - friend class EntityView; - - EntityViewConstIterator(EntityIndex index); - - EntityViewConstIterator& operator++(); - - EntityViewConstIterator operator++(int); - - EntityViewConstIterator& operator--(); - - EntityViewConstIterator operator--(int); - - const Entity operator*(); - - const Entity operator[](int index); - - - bool operator==(EntityViewConstIterator); - bool operator!=(EntityViewConstIterator); - -private: - EntityIndex m_currentEntity; -}; - class EntityView { public: @@ -63,8 +10,40 @@ public: EntityView() = delete; EntityView(EntityIndex, EntityIndex); - using iterator = EntityViewIterator; - using const_iterator = EntityViewConstIterator; + + class iterator + { + public: + iterator(EntityIndex); + iterator& operator++(); + iterator operator++(int); + iterator& operator--(); + iterator operator--(int); + Entity operator*(); + Entity operator[](int); + bool operator==(iterator); + bool operator!=(iterator); + private: + EntityIndex m_currentEntity; + }; + + class const_iterator + { + public: + const_iterator(EntityIndex index); + const_iterator& operator++(); + const_iterator operator++(int); + const_iterator& operator--(); + const_iterator operator--(int); + const Entity operator*(); + const Entity operator[](int index); + bool operator==(const_iterator); + bool operator!=(const_iterator); + private: + EntityIndex m_currentEntity; + }; + + Entity operator[](EntityIndex) const; iterator begin() { return iterator(m_start); } iterator end() { return iterator(m_start + m_size); } diff --git a/include/utility.h b/include/utility.h index eb2f225..9fb38e0 100644 --- a/include/utility.h +++ b/include/utility.h @@ -12,10 +12,11 @@ using s8 = int8_t; using s16 = int16_t; using s32 = int32_t; using s64 = int64_t; +using tag_type = u8; using EntityIndex = u16; -enum EntityTag : u8 +enum class Tag : tag_type { player, tile, @@ -23,8 +24,6 @@ enum EntityTag : u8 tagCount }; - - namespace util { using namespace std::string_view_literals; @@ -33,28 +32,36 @@ namespace util inline constexpr EntityIndex MAX_TILES {1'000u}; inline constexpr EntityIndex MAX_ENEMIES {1'000u}; inline constexpr EntityIndex MAX_ENTITIES {MAX_PLAYERS + MAX_TILES + MAX_ENEMIES}; + inline constexpr tag_type TAG_COUNT {(tag_type)Tag::tagCount}; // used for imgui - inline constexpr std::array tagStringsC = + inline constexpr char* tagStringsC[TAG_COUNT] = { "player", "tile", - "enemy" + "enemy", }; - inline constexpr std::array tagStrings = + inline constexpr std::string_view tagStrings[TAG_COUNT] = { "player"sv, "tile"sv, - "enemy"sv + "enemy"sv, }; - inline constexpr std::array tagStart = + inline constexpr EntityIndex tagStart[TAG_COUNT] = { 0,//player 1,//tile start MAX_TILES,//enemy start }; + + inline constexpr EntityIndex tagSize[TAG_COUNT] = + { + MAX_PLAYERS, + MAX_TILES, + MAX_ENEMIES, + }; } diff --git a/premake5.lua b/premake5.lua index 1d30ca6..3c5bbf0 100644 --- a/premake5.lua +++ b/premake5.lua @@ -153,15 +153,16 @@ project "2d-platformer" --config settings filter "configurations:debug" - defines"LOG_ENABLE" - symbols "on" - runtime "Debug" - kind "ConsoleApp" + defines {"LOG_ENABLE", "GAME_DEBUG"} + symbols "on" + runtime "Debug" + kind "ConsoleApp" filter "configurations:release" - optimize "Speed" - inlining "Auto" - symbols "off" - runtime "Release" - kind "WindowedApp" - entrypoint "mainCRTStartup" + defines {"GAME_RELEASE"} + optimize "Speed" + inlining "Auto" + symbols "off" + runtime "Release" + kind "WindowedApp" + entrypoint "mainCRTStartup" diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index bf69fb7..6239d30 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -23,25 +23,19 @@ T& Entity::getComponent() const } template -T& Entity::getComponent() -{ - return EntityMemoryPool::instance().getComponent(m_index); -} - -template -void Entity::addComponent(const T&& data) +void Entity::addComponent(const T& data) { T& component = EntityMemoryPool::instance().getComponent(m_index); component = data; component.active = true; } -EntityIndex Entity::id() const +size_t Entity::id() const { return EntityMemoryPool::instance().getId(m_index); } -EntityTag Entity::tag() const +Tag Entity::tag() const { return EntityMemoryPool::instance().getTag(m_index); } diff --git a/src/Entities/EntityManager.cpp b/src/Entities/EntityManager.cpp index e18fa01..10d1264 100644 --- a/src/Entities/EntityManager.cpp +++ b/src/Entities/EntityManager.cpp @@ -1,9 +1,10 @@ #include "Entities/EntityView.h" -#include "utility.h" #include #include -inline constexpr EntityIndex PLAYER_INDEX = 0; +#include "utility.h" + +inline constexpr EntityIndex PLAYER_INDEX = util::tagStart[(tag_type)Tag::player]; void EntityManager::update() { @@ -12,10 +13,10 @@ void EntityManager::update() inline Entity EntityManager::player() { - return m_player; + return Entity(PLAYER_INDEX); } -EntityView EntityManager::getEntiites(EntityTag tag) +EntityView EntityManager::getEntiites(Tag tag) { - return EntityView(util::tagStart[tag], m_numEntitiesByTag[tag]); -} \ No newline at end of file + return EntityView(util::tagStart[(tag_type)tag], m_numEntitiesByTag[(tag_type)tag]); +} diff --git a/src/Entities/EntityMemoryPool.cpp b/src/Entities/EntityMemoryPool.cpp index 63e6473..4aa5ca7 100644 --- a/src/Entities/EntityMemoryPool.cpp +++ b/src/Entities/EntityMemoryPool.cpp @@ -4,55 +4,22 @@ #include #include #include +#include EntityMemoryPool::EntityMemoryPool() { + /* std::apply([=](auto&&... args) {((args.reserve(util::MAX_ENTITIES)), ...); }, m_components); m_tags.reserve(util::MAX_ENTITIES); m_aliveStates.reserve(util::MAX_ENTITIES); -} + */ -EntityMemoryPool& EntityMemoryPool::instance() -{ - static EntityMemoryPool pool{}; - return pool; -} - -template -bool EntityMemoryPool::hasComponent(EntityIndex index) const -{ - return std::get>(m_components)[index].active; -} - -template -T& EntityMemoryPool::getComponent(EntityIndex index) const -{ - return std::get>(m_components)[index]; -} - -template -T& EntityMemoryPool::getComponent(EntityIndex index) -{ - return std::get>(m_components)[index]; -} - -EntityTag EntityMemoryPool::getTag(EntityIndex index) const -{ - return m_tags[index]; -} - -bool EntityMemoryPool::getAlive(EntityIndex index) const -{ - return m_aliveStates[index]; -} - -size_t EntityMemoryPool::getId(EntityIndex index) const -{ - return m_ids[index]; -} - -void EntityMemoryPool::removeEntity(EntityIndex index) -{ - m_aliveStates[index] = false; - return; + for (int i = 0; i < util::TAG_COUNT; i++) + { + EntityView x(util::tagStart[i], util::tagSize[i]); + for (auto entity : x) + { + m_tags[entity.m_index] = (Tag)i; + } + } } \ No newline at end of file diff --git a/src/Entities/EntityView.cpp b/src/Entities/EntityView.cpp index a19ddcc..4d92848 100644 --- a/src/Entities/EntityView.cpp +++ b/src/Entities/EntityView.cpp @@ -5,109 +5,111 @@ EntityView::EntityView(EntityIndex start, EntityIndex size) : m_start(start) , m_size(size) -{ +{ } +Entity EntityView::operator[](EntityIndex index) const +{ + return Entity(m_start + index); } - //non-const iterator -EntityViewIterator::EntityViewIterator(EntityIndex index) +EntityView::iterator::iterator(EntityIndex index) : m_currentEntity(index) { } -EntityViewIterator& EntityViewIterator::operator++() +EntityView::iterator& EntityView::iterator::operator++() { m_currentEntity++; return *this; } -EntityViewIterator EntityViewIterator::operator++(int) +EntityView::iterator EntityView::iterator::operator++(int) { m_currentEntity++; return m_currentEntity - 1; } -EntityViewIterator& EntityViewIterator::operator--() +EntityView::iterator& EntityView::iterator::operator--() { m_currentEntity--; return *this; } -EntityViewIterator EntityViewIterator::operator--(int) +EntityView::iterator EntityView::iterator::operator--(int) { m_currentEntity--; return m_currentEntity + 1; } -Entity EntityViewIterator::operator*() +Entity EntityView::iterator::operator*() { return m_currentEntity; } -Entity EntityViewIterator::operator[](int index) +Entity EntityView::iterator::operator[](int index) { return m_currentEntity + index; } -bool EntityViewIterator::operator==(EntityViewIterator other) +bool EntityView::iterator::operator==(iterator other) { return m_currentEntity == other.m_currentEntity; } -bool EntityViewIterator::operator!=(EntityViewIterator other) +bool EntityView::iterator::operator!=(iterator other) { return m_currentEntity != other.m_currentEntity; } //const iterator -EntityViewConstIterator::EntityViewConstIterator(EntityIndex index) +EntityView::const_iterator::const_iterator(EntityIndex index) : m_currentEntity(index) { } -EntityViewConstIterator& EntityViewConstIterator::operator++() +EntityView::const_iterator& EntityView::const_iterator::operator++() { m_currentEntity++; return *this; } -EntityViewConstIterator EntityViewConstIterator::operator++(int) +EntityView::const_iterator EntityView::const_iterator::operator++(int) { m_currentEntity++; return m_currentEntity - 1; } -EntityViewConstIterator& EntityViewConstIterator::operator--() +EntityView::const_iterator& EntityView::const_iterator::operator--() { m_currentEntity--; return *this; } -EntityViewConstIterator EntityViewConstIterator::operator--(int) +EntityView::const_iterator EntityView::const_iterator::operator--(int) { m_currentEntity--; return m_currentEntity + 1; } -const Entity EntityViewConstIterator::operator*() +const Entity EntityView::const_iterator::operator*() { return m_currentEntity; } -const Entity EntityViewConstIterator::operator[](int index) +const Entity EntityView::const_iterator::operator[](int index) { return m_currentEntity + index; } -bool EntityViewConstIterator::operator==(EntityViewConstIterator other) +bool EntityView::const_iterator::operator==(EntityView::const_iterator other) { return m_currentEntity == other.m_currentEntity; } -bool EntityViewConstIterator::operator!=(EntityViewConstIterator other) +bool EntityView::const_iterator::operator!=(EntityView::const_iterator other) { return m_currentEntity != other.m_currentEntity; } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 66a143b..434d30d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ -#include "Containers/Array.h" +#include "Containers.h" #include "log.h" #include #include @@ -12,8 +12,6 @@ int main() { - container::Array arr; - auto window = sf::RenderWindow(sf::VideoMode({ 1920u, 1080u }), "Fake Mario"); window.setFramerateLimit(144); if (!ImGui::SFML::Init(window))