major update
-added custom Array container with iterator support and a space effecient bool specializaton -changed tabs from spaces to indents -renamed src/Classes to src/Entities
This commit is contained in:
parent
1f4826fcc4
commit
2a9e531711
|
|
@ -383,4 +383,6 @@ Makefile
|
||||||
|
|
||||||
*.d
|
*.d
|
||||||
|
|
||||||
*.ninja*
|
*.ninja*
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
|
@ -11,6 +11,6 @@ Pos=60,60
|
||||||
Size=536,286
|
Size=536,286
|
||||||
|
|
||||||
[Window][sdfkjasbdf]
|
[Window][sdfkjasbdf]
|
||||||
Pos=249,161
|
Pos=679,86
|
||||||
Size=610,481
|
Size=610,481
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Containers/Array.h>
|
||||||
|
|
@ -0,0 +1,451 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "utility.h"
|
||||||
|
#include <cstddef>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
|
namespace container
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T, EntityIndex capacity>
|
||||||
|
class Array
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using data_type = T;
|
||||||
|
using pointer = data_type*;
|
||||||
|
using reference = data_type&;
|
||||||
|
using const_pointer = const pointer;
|
||||||
|
using const_reference = const data_type&;
|
||||||
|
using difference_type = std::ptrdiff_t;
|
||||||
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
|
||||||
|
public:
|
||||||
|
class Iterator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Iterator(const_pointer input)
|
||||||
|
: m_ptr(input)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
Iterator& operator++()
|
||||||
|
{
|
||||||
|
m_ptr++;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator operator++(int)
|
||||||
|
{
|
||||||
|
auto it = *this;
|
||||||
|
m_ptr++;
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator& operator--()
|
||||||
|
{
|
||||||
|
m_ptr--;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Iterator operator--(int)
|
||||||
|
{
|
||||||
|
auto it = *this;
|
||||||
|
m_ptr++;
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
reference operator[](const int 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; }
|
||||||
|
private:
|
||||||
|
pointer m_ptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConstIterator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ConstIterator(const_pointer input)
|
||||||
|
: m_ptr(input)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
ConstIterator& operator++()
|
||||||
|
{
|
||||||
|
m_ptr++;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConstIterator operator++(int)
|
||||||
|
{
|
||||||
|
auto it = *this;
|
||||||
|
m_ptr++;
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConstIterator& operator--()
|
||||||
|
{
|
||||||
|
m_ptr--;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ConstIterator operator--(int)
|
||||||
|
{
|
||||||
|
auto it = *this;
|
||||||
|
m_ptr++;
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const_reference operator[](const int 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; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
pointer m_ptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
Array() { m_data = new T[capacity]; }
|
||||||
|
|
||||||
|
~Array() { delete[] m_data; }
|
||||||
|
|
||||||
|
Array<T, capacity>(const Array<T, capacity>&) = delete;
|
||||||
|
|
||||||
|
Array(Array&& other)
|
||||||
|
: m_data(other.m_data)
|
||||||
|
{
|
||||||
|
other.m_data = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Array& operator=(Array&& other)
|
||||||
|
{
|
||||||
|
if (this != &other)
|
||||||
|
{
|
||||||
|
delete[] m_data;
|
||||||
|
m_data = other.m_data;
|
||||||
|
other.m_data = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pointer data() { return m_data; }
|
||||||
|
|
||||||
|
reference operator[](const int index) { return m_data[index]; }
|
||||||
|
|
||||||
|
const_reference operator[](const int index) const { return m_data[index]; }
|
||||||
|
|
||||||
|
inline constexpr EntityIndex size() { return capacity; }
|
||||||
|
|
||||||
|
Iterator begin() { return Iterator(m_data); }
|
||||||
|
Iterator end() { return Iterator(m_data + capacity); }
|
||||||
|
|
||||||
|
ConstIterator cbegin() const { return ConstIterator(m_data); }
|
||||||
|
ConstIterator cend() const { return ConstIterator(m_data + capacity); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
pointer m_data;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <EntityIndex capacity>
|
||||||
|
class Array<bool, capacity>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
class reference;
|
||||||
|
class const_reference;
|
||||||
|
using data_type = u8;
|
||||||
|
using pointer = reference;
|
||||||
|
using const_pointer = const_reference;
|
||||||
|
using difference_type = std::ptrdiff_t;
|
||||||
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
|
||||||
|
public:
|
||||||
|
class reference
|
||||||
|
{
|
||||||
|
friend class Array;
|
||||||
|
reference(data_type* ptr_in, u8 mask_in)
|
||||||
|
: m_ptr(ptr_in)
|
||||||
|
, m_mask(mask_in)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
~reference()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
reference(const reference&) = default;
|
||||||
|
|
||||||
|
operator bool () const
|
||||||
|
{
|
||||||
|
return !!(*m_ptr & m_mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
reference& operator=(bool input)
|
||||||
|
{
|
||||||
|
if (input)
|
||||||
|
{
|
||||||
|
*m_ptr |= m_mask;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*m_ptr &= m_mask;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
reference& operator=(const reference& other)
|
||||||
|
{
|
||||||
|
return *this = bool(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
void flip()
|
||||||
|
{
|
||||||
|
*m_ptr ^= m_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
data_type* m_ptr;
|
||||||
|
u8 m_mask;
|
||||||
|
};
|
||||||
|
|
||||||
|
class const_reference
|
||||||
|
{
|
||||||
|
friend class Array;
|
||||||
|
const_reference(data_type* ptr_in, u8 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;
|
||||||
|
void flip() = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const data_type* m_ptr;
|
||||||
|
u8 m_mask;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Iterator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Iterator(data_type* input, u8 index)
|
||||||
|
: m_ptr(input)
|
||||||
|
, m_currentClusterIndex(index)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
Iterator& operator++()
|
||||||
|
{
|
||||||
|
if (m_currentClusterIndex++ == 7)
|
||||||
|
{
|
||||||
|
m_currentClusterIndex = 0;
|
||||||
|
m_ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator operator++(int)
|
||||||
|
{
|
||||||
|
auto it = *this;
|
||||||
|
if (m_currentClusterIndex++ == 7)
|
||||||
|
{
|
||||||
|
m_ptr++;
|
||||||
|
m_currentClusterIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator& operator--()
|
||||||
|
{
|
||||||
|
if (m_currentClusterIndex-- == 0)
|
||||||
|
{
|
||||||
|
m_ptr--;
|
||||||
|
m_currentClusterIndex = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator operator--(int)
|
||||||
|
{
|
||||||
|
auto it = *this;
|
||||||
|
if (m_currentClusterIndex-- == 0)
|
||||||
|
{
|
||||||
|
m_ptr--;
|
||||||
|
m_currentClusterIndex = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator[](const int) = delete;
|
||||||
|
reference operator*() const
|
||||||
|
{
|
||||||
|
return reference(m_ptr, 1 << m_currentClusterIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const Iterator& other) const
|
||||||
|
{
|
||||||
|
return (m_ptr == other.m_ptr) && (m_currentClusterIndex == other.m_currentClusterIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const Iterator& other) const
|
||||||
|
{
|
||||||
|
return (m_ptr != other.m_ptr) || (m_currentClusterIndex != other.m_currentClusterIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
data_type* m_ptr;
|
||||||
|
u8 m_currentClusterIndex{};
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConstIterator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ConstIterator(const data_type* input, u8 index)
|
||||||
|
: m_ptr(input)
|
||||||
|
, m_currentClusterIndex(index)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
ConstIterator& operator++()
|
||||||
|
{
|
||||||
|
if (m_currentClusterIndex++ == 7)
|
||||||
|
{
|
||||||
|
m_currentClusterIndex = 0;
|
||||||
|
m_ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConstIterator operator++(int)
|
||||||
|
{
|
||||||
|
auto it = *this;
|
||||||
|
if (m_currentClusterIndex++ == 7)
|
||||||
|
{
|
||||||
|
m_ptr++;
|
||||||
|
m_currentClusterIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConstIterator& operator--()
|
||||||
|
{
|
||||||
|
if (m_currentClusterIndex-- == 0)
|
||||||
|
{
|
||||||
|
m_ptr--;
|
||||||
|
m_currentClusterIndex = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConstIterator operator--(int)
|
||||||
|
{
|
||||||
|
auto it = *this;
|
||||||
|
if (m_currentClusterIndex-- == 0)
|
||||||
|
{
|
||||||
|
m_ptr--;
|
||||||
|
m_currentClusterIndex = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator[](const int) = delete;
|
||||||
|
const_reference operator*() const
|
||||||
|
{
|
||||||
|
return const_reference(m_ptr, 1 << m_currentClusterIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const ConstIterator& other) const
|
||||||
|
{ return (m_ptr == other.m_ptr) && (m_currentClusterIndex == other.m_currentClusterIndex); }
|
||||||
|
|
||||||
|
|
||||||
|
bool operator!=(const ConstIterator& other) const
|
||||||
|
{ return (m_ptr != other.m_ptr) || (m_currentClusterIndex != other.m_currentClusterIndex); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
const data_type* m_ptr;
|
||||||
|
u8 m_currentClusterIndex{};
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
Array() { m_data = new data_type[(capacity / 8) + 1]; }
|
||||||
|
|
||||||
|
~Array() { delete[] m_data; }
|
||||||
|
|
||||||
|
Array<bool, capacity>(const Array<bool, capacity>&) = delete;
|
||||||
|
|
||||||
|
Array(Array&& other)
|
||||||
|
: m_data(other.m_data)
|
||||||
|
{
|
||||||
|
other.m_data = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Array& operator=(Array&& other)
|
||||||
|
{
|
||||||
|
if (this != &other)
|
||||||
|
{
|
||||||
|
delete[] m_data;
|
||||||
|
m_data = other.m_data;
|
||||||
|
other.m_data = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
data_type* data() { return m_data; }
|
||||||
|
|
||||||
|
//use readAt() instead
|
||||||
|
reference operator[](int index)
|
||||||
|
{
|
||||||
|
return reference(m_data + (index / 8), 1 << (index % 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr EntityIndex size() { return capacity; }
|
||||||
|
|
||||||
|
bool readAt(const int index) const { return m_data[index / 8] & (1 << (index % 8)); }
|
||||||
|
|
||||||
|
void setTrueAt(const int index) { m_data[index / 8] |= (1 << (index % 8)); }
|
||||||
|
|
||||||
|
void setFalseAt(const int index) { m_data[index / 8] &= ~(1 << (index % 8)); }
|
||||||
|
|
||||||
|
Iterator begin() { return Iterator(m_data, 0); }
|
||||||
|
Iterator end() { return Iterator(m_data + (capacity / 8), capacity % 8); }
|
||||||
|
|
||||||
|
ConstIterator cbegin() const { return ConstIterator(m_data, 0); }
|
||||||
|
ConstIterator cend() const { return ConstIterator(m_data + (capacity / 8), capacity % 8); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
data_type* m_data;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}//namespace
|
||||||
|
|
@ -17,11 +17,11 @@ public:
|
||||||
sf::Vector2f position{};
|
sf::Vector2f position{};
|
||||||
sf::Vector2f speed{};
|
sf::Vector2f speed{};
|
||||||
|
|
||||||
Transform() = default;
|
Transform() = default;
|
||||||
Transform(sf::Vector2f position_in, sf::Vector2f speed_in)
|
Transform(sf::Vector2f position_in, sf::Vector2f speed_in)
|
||||||
: position(position_in)
|
: position(position_in)
|
||||||
, speed(speed_in)
|
, speed(speed_in)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,31 +11,31 @@ class Entity
|
||||||
//private:
|
//private:
|
||||||
public:
|
public:
|
||||||
friend class EntityManager;
|
friend class EntityManager;
|
||||||
friend class EntityViewIterator;
|
friend class EntityViewIterator;
|
||||||
friend class EntityViewConstIterator;
|
friend class EntityViewConstIterator;
|
||||||
|
|
||||||
Entity() = delete;
|
Entity() = delete;
|
||||||
Entity(EntityIndex);
|
Entity(EntityIndex);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool hasComponent() const;
|
bool hasComponent() const;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T& getComponent() const;
|
T& getComponent() const;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T& getComponent();
|
T& getComponent();
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void addComponent(const T&&);
|
void addComponent(const T&&);
|
||||||
|
|
||||||
EntityIndex id() const;
|
EntityIndex id() const;
|
||||||
|
|
||||||
EntityTag tag() const;
|
EntityTag tag() const;
|
||||||
|
|
||||||
bool isAlive() const;
|
bool isAlive() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EntityIndex m_id;
|
EntityIndex m_index;
|
||||||
};
|
};
|
||||||
|
|
@ -8,12 +8,14 @@
|
||||||
|
|
||||||
class EntityManager
|
class EntityManager
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
void update();
|
||||||
private:
|
private:
|
||||||
EntityView getEntiites(EntityTag);
|
EntityView getEntiites(EntityTag);
|
||||||
|
|
||||||
inline Entity player();
|
inline Entity player();
|
||||||
private:
|
private:
|
||||||
Entity m_player{0};
|
Entity m_player{0};
|
||||||
std::array<u16, tagCount> m_numEntitiesByTag{};
|
std::array<u16, tagCount> m_numEntitiesByTag{};
|
||||||
u16 m_numEntities{};
|
u16 m_numEntities{};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "utility.h"
|
||||||
|
#include <cstddef>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
@ -19,27 +21,30 @@ private:
|
||||||
ComponentVectorTuple m_components;
|
ComponentVectorTuple m_components;
|
||||||
std::vector<EntityTag> m_tags;
|
std::vector<EntityTag> m_tags;
|
||||||
std::vector<bool> m_aliveStates;
|
std::vector<bool> m_aliveStates;
|
||||||
|
std::vector<size_t> m_ids;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EntityMemoryPool();
|
EntityMemoryPool();
|
||||||
|
|
||||||
EntityMemoryPool(const EntityMemoryPool&) = delete;
|
EntityMemoryPool(const EntityMemoryPool&) = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static EntityMemoryPool& instance();
|
static EntityMemoryPool& instance();
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool hasComponent(EntityIndex) const;
|
bool hasComponent(EntityIndex) const;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T& getComponent(EntityIndex) const;
|
T& getComponent(EntityIndex) const;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T& getComponent(EntityIndex);
|
T& getComponent(EntityIndex);
|
||||||
|
|
||||||
EntityTag getTag(EntityIndex) const;
|
EntityTag getTag(EntityIndex) const;
|
||||||
|
|
||||||
bool getAlive(EntityIndex) const;
|
bool getAlive(EntityIndex) const;
|
||||||
|
|
||||||
void removeEntity(EntityIndex);
|
size_t getId(EntityIndex) const;
|
||||||
|
|
||||||
|
void removeEntity(EntityIndex);
|
||||||
};
|
};
|
||||||
|
|
@ -7,77 +7,72 @@ class EntityView;
|
||||||
|
|
||||||
class EntityViewIterator
|
class EntityViewIterator
|
||||||
{
|
{
|
||||||
friend class EntityView;
|
friend class EntityView;
|
||||||
|
|
||||||
EntityViewIterator(EntityIndex);
|
EntityViewIterator(EntityIndex);
|
||||||
|
|
||||||
EntityViewIterator& operator++();
|
EntityViewIterator& operator++();
|
||||||
|
|
||||||
EntityViewIterator operator++(int);
|
EntityViewIterator operator++(int);
|
||||||
|
|
||||||
EntityViewIterator& operator--();
|
EntityViewIterator& operator--();
|
||||||
|
|
||||||
EntityViewIterator operator--(int);
|
EntityViewIterator operator--(int);
|
||||||
|
|
||||||
Entity operator*();
|
Entity operator*();
|
||||||
|
|
||||||
Entity operator[](int);
|
Entity operator[](int);
|
||||||
Entity* operator->();
|
|
||||||
|
|
||||||
bool operator==(EntityViewIterator);
|
bool operator==(EntityViewIterator);
|
||||||
bool operator!=(EntityViewIterator);
|
bool operator!=(EntityViewIterator);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Entity m_currentEntity;
|
EntityIndex m_currentEntity;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EntityViewConstIterator
|
class EntityViewConstIterator
|
||||||
{
|
{
|
||||||
friend class EntityView;
|
friend class EntityView;
|
||||||
|
|
||||||
EntityViewConstIterator(EntityIndex index);
|
EntityViewConstIterator(EntityIndex index);
|
||||||
|
|
||||||
EntityViewConstIterator& operator++();
|
EntityViewConstIterator& operator++();
|
||||||
|
|
||||||
EntityViewConstIterator operator++(int);
|
EntityViewConstIterator operator++(int);
|
||||||
|
|
||||||
EntityViewConstIterator& operator--();
|
EntityViewConstIterator& operator--();
|
||||||
|
|
||||||
EntityViewConstIterator operator--(int);
|
EntityViewConstIterator operator--(int);
|
||||||
|
|
||||||
const Entity operator*();
|
const Entity operator*();
|
||||||
|
|
||||||
const Entity operator[](int index);
|
const Entity operator[](int index);
|
||||||
|
|
||||||
const Entity* operator->();
|
|
||||||
|
|
||||||
|
|
||||||
bool operator==(EntityViewConstIterator);
|
bool operator==(EntityViewConstIterator);
|
||||||
bool operator!=(EntityViewConstIterator);
|
bool operator!=(EntityViewConstIterator);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Entity m_currentEntity;
|
EntityIndex m_currentEntity;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EntityView
|
class EntityView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
friend class EntityManager;
|
friend class EntityManager;
|
||||||
EntityView() = delete;
|
EntityView() = delete;
|
||||||
EntityView(EntityIndex, EntityIndex);
|
EntityView(EntityIndex, EntityIndex);
|
||||||
|
|
||||||
using iterator = EntityViewIterator;
|
using iterator = EntityViewIterator;
|
||||||
using const_iterator = EntityViewConstIterator;
|
using const_iterator = EntityViewConstIterator;
|
||||||
|
|
||||||
iterator begin() { return iterator(m_start); }
|
iterator begin() { return iterator(m_start); }
|
||||||
iterator end() { return iterator(m_start + m_size); }
|
iterator end() { return iterator(m_start + m_size); }
|
||||||
|
|
||||||
|
const_iterator cbegin() const { return const_iterator(m_start); }
|
||||||
|
const_iterator cend() const { return const_iterator(m_start + m_size); }
|
||||||
const_iterator cbegin() const { return const_iterator(m_start); }
|
|
||||||
const_iterator cend() const { return const_iterator(m_start + m_size); }
|
|
||||||
private:
|
private:
|
||||||
EntityIndex m_start;
|
EntityIndex m_start;
|
||||||
EntityIndex m_size;
|
EntityIndex m_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,9 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#ifdef LOG_ENABLE
|
#ifdef LOG_ENABLE
|
||||||
|
#define LOG_CONDITON(x) if (x)
|
||||||
#define LOG(x) std::cout << x << "\n"
|
#define LOG(x) std::cout << x << "\n"
|
||||||
#else
|
#else
|
||||||
#define LOG(x)
|
#define LOG(x)
|
||||||
|
#define LOG_CONDITON(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -17,10 +17,10 @@ using EntityIndex = u16;
|
||||||
|
|
||||||
enum EntityTag : u8
|
enum EntityTag : u8
|
||||||
{
|
{
|
||||||
player,
|
player,
|
||||||
tile,
|
tile,
|
||||||
enemy,
|
enemy,
|
||||||
tagCount
|
tagCount
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -29,28 +29,32 @@ namespace util
|
||||||
{
|
{
|
||||||
using namespace std::string_view_literals;
|
using namespace std::string_view_literals;
|
||||||
|
|
||||||
|
inline constexpr EntityIndex MAX_PLAYERS{1u};
|
||||||
inline constexpr EntityIndex MAX_ENTITIES {60'000u};
|
inline constexpr EntityIndex MAX_TILES {1'000u};
|
||||||
inline constexpr EntityIndex MAX_TILES {1'000u};
|
inline constexpr EntityIndex MAX_ENEMIES {1'000u};
|
||||||
inline constexpr EntityIndex MAX_ENEMIES {1'000u};
|
inline constexpr EntityIndex MAX_ENTITIES {MAX_PLAYERS + MAX_TILES + MAX_ENEMIES};
|
||||||
|
|
||||||
// used for imgui
|
// used for imgui
|
||||||
inline constexpr std::array<const char*, tagCount> tagStringsC =
|
inline constexpr std::array<const char*, tagCount> tagStringsC =
|
||||||
{
|
{
|
||||||
"player"
|
"player",
|
||||||
|
"tile",
|
||||||
|
"enemy"
|
||||||
};
|
};
|
||||||
|
|
||||||
inline constexpr std::array<std::string_view, tagCount> tagStrings =
|
inline constexpr std::array<std::string_view, tagCount> tagStrings =
|
||||||
{
|
{
|
||||||
"player"sv
|
"player"sv,
|
||||||
|
"tile"sv,
|
||||||
|
"enemy"sv
|
||||||
};
|
};
|
||||||
|
|
||||||
inline constexpr std::array<EntityIndex, tagCount> tagStart =
|
inline constexpr std::array<EntityIndex, tagCount> tagStart =
|
||||||
{
|
{
|
||||||
0,//player
|
0,//player
|
||||||
1,//tile start
|
1,//tile start
|
||||||
MAX_TILES,//enemy start
|
MAX_TILES,//enemy start
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
#include <Entities/Entity.h>
|
|
||||||
#include <Entities/Components.h>
|
|
||||||
#include <Entities/EntityMemoryPool.h>
|
|
||||||
|
|
||||||
#include <utility.h>
|
|
||||||
|
|
||||||
Entity::Entity(EntityIndex id_in)
|
|
||||||
: m_id(id_in)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
bool Entity::hasComponent() const
|
|
||||||
{
|
|
||||||
return EntityMemoryPool::instance().hasComponent<T>(m_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T& Entity::getComponent() const
|
|
||||||
{
|
|
||||||
return EntityMemoryPool::instance().getComponent<T>(m_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T& Entity::getComponent()
|
|
||||||
{
|
|
||||||
return EntityMemoryPool::instance().getComponent<T>(m_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void Entity::addComponent(const T&& data)
|
|
||||||
{
|
|
||||||
T& component = EntityMemoryPool::instance().getComponent<T>(m_id);
|
|
||||||
component = data;
|
|
||||||
component.active = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
EntityIndex Entity::id() const
|
|
||||||
{
|
|
||||||
return m_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
EntityTag Entity::tag() const
|
|
||||||
{
|
|
||||||
return EntityMemoryPool::instance().getTag(m_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Entity::isAlive() const
|
|
||||||
{
|
|
||||||
return EntityMemoryPool::instance().getAlive(m_id);
|
|
||||||
}
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
#include <Entities/EntityMemoryPool.h>
|
|
||||||
|
|
||||||
#include <Entities/Entity.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <utility.h>
|
|
||||||
|
|
||||||
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<typename T>
|
|
||||||
bool EntityMemoryPool::hasComponent(EntityIndex id) const
|
|
||||||
{
|
|
||||||
return std::get<std::vector<T>>(m_components)[id].active;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T& EntityMemoryPool::getComponent(EntityIndex id) const
|
|
||||||
{
|
|
||||||
return std::get<std::vector<T>>(m_components)[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T& EntityMemoryPool::getComponent(EntityIndex id)
|
|
||||||
{
|
|
||||||
return std::get<std::vector<T>>(m_components)[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
EntityTag EntityMemoryPool::getTag(EntityIndex id) const
|
|
||||||
{
|
|
||||||
return m_tags[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EntityMemoryPool::getAlive(EntityIndex id) const
|
|
||||||
{
|
|
||||||
return m_aliveStates[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
void EntityMemoryPool::removeEntity(EntityIndex id)
|
|
||||||
{
|
|
||||||
m_aliveStates[id] = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
#include <Entities/Entity.h>
|
||||||
|
#include <Entities/Components.h>
|
||||||
|
#include <Entities/EntityMemoryPool.h>
|
||||||
|
|
||||||
|
#include <utility.h>
|
||||||
|
|
||||||
|
Entity::Entity(EntityIndex index_in)
|
||||||
|
: m_index(index_in)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool Entity::hasComponent() const
|
||||||
|
{
|
||||||
|
return EntityMemoryPool::instance().hasComponent<T>(m_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T& Entity::getComponent() const
|
||||||
|
{
|
||||||
|
return EntityMemoryPool::instance().getComponent<T>(m_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T& Entity::getComponent()
|
||||||
|
{
|
||||||
|
return EntityMemoryPool::instance().getComponent<T>(m_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void Entity::addComponent(const T&& data)
|
||||||
|
{
|
||||||
|
T& component = EntityMemoryPool::instance().getComponent<T>(m_index);
|
||||||
|
component = data;
|
||||||
|
component.active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityIndex Entity::id() const
|
||||||
|
{
|
||||||
|
return EntityMemoryPool::instance().getId(m_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityTag Entity::tag() const
|
||||||
|
{
|
||||||
|
return EntityMemoryPool::instance().getTag(m_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Entity::isAlive() const
|
||||||
|
{
|
||||||
|
return EntityMemoryPool::instance().getAlive(m_index);
|
||||||
|
}
|
||||||
|
|
@ -5,12 +5,17 @@
|
||||||
|
|
||||||
inline constexpr EntityIndex PLAYER_INDEX = 0;
|
inline constexpr EntityIndex PLAYER_INDEX = 0;
|
||||||
|
|
||||||
|
void EntityManager::update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
inline Entity EntityManager::player()
|
inline Entity EntityManager::player()
|
||||||
{
|
{
|
||||||
return m_player;
|
return m_player;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityView EntityManager::getEntiites(EntityTag tag)
|
EntityView EntityManager::getEntiites(EntityTag tag)
|
||||||
{
|
{
|
||||||
return EntityView(util::tagStart[tag], m_numEntitiesByTag[tag]);
|
return EntityView(util::tagStart[tag], m_numEntitiesByTag[tag]);
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
#include <Entities/EntityMemoryPool.h>
|
||||||
|
|
||||||
|
#include <Entities/Entity.h>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <vector>
|
||||||
|
#include <utility.h>
|
||||||
|
|
||||||
|
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<typename T>
|
||||||
|
bool EntityMemoryPool::hasComponent(EntityIndex index) const
|
||||||
|
{
|
||||||
|
return std::get<std::vector<T>>(m_components)[index].active;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T& EntityMemoryPool::getComponent(EntityIndex index) const
|
||||||
|
{
|
||||||
|
return std::get<std::vector<T>>(m_components)[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T& EntityMemoryPool::getComponent(EntityIndex index)
|
||||||
|
{
|
||||||
|
return std::get<std::vector<T>>(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;
|
||||||
|
}
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
EntityView::EntityView(EntityIndex start, EntityIndex size)
|
EntityView::EntityView(EntityIndex start, EntityIndex size)
|
||||||
: m_start(start)
|
: m_start(start)
|
||||||
, m_size(size)
|
, m_size(size)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -12,112 +12,102 @@ EntityView::EntityView(EntityIndex start, EntityIndex size)
|
||||||
|
|
||||||
//non-const iterator
|
//non-const iterator
|
||||||
EntityViewIterator::EntityViewIterator(EntityIndex index)
|
EntityViewIterator::EntityViewIterator(EntityIndex index)
|
||||||
: m_currentEntity(index)
|
: m_currentEntity(index)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityViewIterator& EntityViewIterator::operator++()
|
EntityViewIterator& EntityViewIterator::operator++()
|
||||||
{
|
{
|
||||||
m_currentEntity.m_id++;
|
m_currentEntity++;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityViewIterator EntityViewIterator::operator++(int)
|
EntityViewIterator EntityViewIterator::operator++(int)
|
||||||
{
|
{
|
||||||
m_currentEntity.m_id++;
|
m_currentEntity++;
|
||||||
return m_currentEntity.m_id - 1;
|
return m_currentEntity - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityViewIterator& EntityViewIterator::operator--()
|
EntityViewIterator& EntityViewIterator::operator--()
|
||||||
{
|
{
|
||||||
m_currentEntity.m_id--;
|
m_currentEntity--;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityViewIterator EntityViewIterator::operator--(int)
|
EntityViewIterator EntityViewIterator::operator--(int)
|
||||||
{
|
{
|
||||||
m_currentEntity.m_id--;
|
m_currentEntity--;
|
||||||
return m_currentEntity.m_id + 1;
|
return m_currentEntity + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity EntityViewIterator::operator*()
|
Entity EntityViewIterator::operator*()
|
||||||
{
|
{
|
||||||
return m_currentEntity;
|
return m_currentEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity EntityViewIterator::operator[](int index)
|
Entity EntityViewIterator::operator[](int index)
|
||||||
{
|
{
|
||||||
return m_currentEntity.m_id + index;
|
return m_currentEntity + index;
|
||||||
}
|
|
||||||
|
|
||||||
Entity* EntityViewIterator::operator->()
|
|
||||||
{
|
|
||||||
return &m_currentEntity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityViewIterator::operator==(EntityViewIterator other)
|
bool EntityViewIterator::operator==(EntityViewIterator other)
|
||||||
{
|
{
|
||||||
return m_currentEntity.m_id == other->m_id;
|
return m_currentEntity == other.m_currentEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityViewIterator::operator!=(EntityViewIterator other)
|
bool EntityViewIterator::operator!=(EntityViewIterator other)
|
||||||
{
|
{
|
||||||
return m_currentEntity.m_id != other->m_id;
|
return m_currentEntity != other.m_currentEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
//const iterator
|
//const iterator
|
||||||
EntityViewConstIterator::EntityViewConstIterator(EntityIndex index)
|
EntityViewConstIterator::EntityViewConstIterator(EntityIndex index)
|
||||||
: m_currentEntity(index)
|
: m_currentEntity(index)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityViewConstIterator& EntityViewConstIterator::operator++()
|
EntityViewConstIterator& EntityViewConstIterator::operator++()
|
||||||
{
|
{
|
||||||
m_currentEntity.m_id++;
|
m_currentEntity++;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityViewConstIterator EntityViewConstIterator::operator++(int)
|
EntityViewConstIterator EntityViewConstIterator::operator++(int)
|
||||||
{
|
{
|
||||||
m_currentEntity.m_id++;
|
m_currentEntity++;
|
||||||
return m_currentEntity.m_id - 1;
|
return m_currentEntity - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityViewConstIterator& EntityViewConstIterator::operator--()
|
EntityViewConstIterator& EntityViewConstIterator::operator--()
|
||||||
{
|
{
|
||||||
m_currentEntity.m_id--;
|
m_currentEntity--;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityViewConstIterator EntityViewConstIterator::operator--(int)
|
EntityViewConstIterator EntityViewConstIterator::operator--(int)
|
||||||
{
|
{
|
||||||
m_currentEntity.m_id--;
|
m_currentEntity--;
|
||||||
return m_currentEntity.m_id + 1;
|
return m_currentEntity + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Entity EntityViewConstIterator::operator*()
|
const Entity EntityViewConstIterator::operator*()
|
||||||
{
|
{
|
||||||
return m_currentEntity;
|
return m_currentEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Entity EntityViewConstIterator::operator[](int index)
|
const Entity EntityViewConstIterator::operator[](int index)
|
||||||
{
|
{
|
||||||
return m_currentEntity.m_id + index;
|
return m_currentEntity + index;
|
||||||
}
|
|
||||||
|
|
||||||
const Entity* EntityViewConstIterator::operator->()
|
|
||||||
{
|
|
||||||
return &m_currentEntity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityViewConstIterator::operator==(EntityViewConstIterator other)
|
bool EntityViewConstIterator::operator==(EntityViewConstIterator other)
|
||||||
{
|
{
|
||||||
return m_currentEntity.m_id == other->m_id;
|
return m_currentEntity == other.m_currentEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityViewConstIterator::operator!=(EntityViewConstIterator other)
|
bool EntityViewConstIterator::operator!=(EntityViewConstIterator other)
|
||||||
{
|
{
|
||||||
return m_currentEntity.m_id != other->m_id;
|
return m_currentEntity != other.m_currentEntity;
|
||||||
}
|
}
|
||||||
51
src/main.cpp
51
src/main.cpp
|
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
#include "Containers/Array.h"
|
||||||
|
#include "log.h"
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
#include <imgui-SFML.h>
|
#include <imgui-SFML.h>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
@ -10,34 +12,35 @@
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
container::Array<bool, 3> arr;
|
||||||
|
|
||||||
auto window = sf::RenderWindow(sf::VideoMode({ 1920u, 1080u }), "Fake Mario");
|
auto window = sf::RenderWindow(sf::VideoMode({ 1920u, 1080u }), "Fake Mario");
|
||||||
window.setFramerateLimit(144);
|
window.setFramerateLimit(144);
|
||||||
if (!ImGui::SFML::Init(window))
|
if (!ImGui::SFML::Init(window))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
sf::Clock clock;
|
sf::Clock clock;
|
||||||
while (window.isOpen())
|
while (window.isOpen())
|
||||||
{
|
{
|
||||||
while (const std::optional event = window.pollEvent())
|
while (const std::optional event = window.pollEvent())
|
||||||
{
|
{
|
||||||
ImGui::SFML::ProcessEvent(window, *event);
|
ImGui::SFML::ProcessEvent(window, *event);
|
||||||
|
|
||||||
if (event->is<sf::Event::Closed>())
|
if (event->is<sf::Event::Closed>())
|
||||||
{
|
{
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
}// end user input loop
|
}// end user input loop
|
||||||
|
|
||||||
ImGui::SFML::Update(window, clock.restart());
|
ImGui::SFML::Update(window, clock.restart());
|
||||||
|
|
||||||
ImGui::Begin("sdfkjasbdf");
|
ImGui::Begin("sdfkjasbdf");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
window.clear();
|
window.clear();
|
||||||
ImGui::SFML::Render(window);
|
ImGui::SFML::Render(window);
|
||||||
window.display();
|
window.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SFML::Shutdown();
|
ImGui::SFML::Shutdown();
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue