aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-06-22 00:07:17 +0100
committerYann Herklotz <ymherklotz@gmail.com>2018-06-22 00:07:17 +0100
commit3cc80b221c34dcc15579dcf8bf7f4fff8c6b5879 (patch)
tree16fc38715f036e259ba858a6dc1e934af248631e
parent8e038f0114a6a2f6d2971ac9772bd0a053e3ccef (diff)
downloadYAGE-3cc80b221c34dcc15579dcf8bf7f4fff8c6b5879.tar.gz
YAGE-3cc80b221c34dcc15579dcf8bf7f4fff8c6b5879.zip
Moving test name
-rw-r--r--tests/component_test.cpp15
-rw-r--r--tests/entity_test.cpp52
2 files changed, 52 insertions, 15 deletions
diff --git a/tests/component_test.cpp b/tests/component_test.cpp
deleted file mode 100644
index e5a381cf..00000000
--- a/tests/component_test.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <yage/entity/entity.h>
-#include <yage/entity/component.h>
-#include <yage/entity/system.h>
-
-struct Position {
- double x;
- double y;
-
- Position(double x_i, double y_i) : x(x_i), y(y_i) {}
-};
-
-int main() {
- EntityManager em();
- Entity player = em.createEntity();
-}
diff --git a/tests/entity_test.cpp b/tests/entity_test.cpp
new file mode 100644
index 00000000..0e40d3ea
--- /dev/null
+++ b/tests/entity_test.cpp
@@ -0,0 +1,52 @@
+#include <yage/entity/component.h>
+#include <yage/entity/entity.h>
+#include <yage/entity/system.h>
+
+using namespace yage;
+
+#include <iostream>
+#include <vector>
+
+struct Position : public Component<Position> {
+ double x;
+ double y;
+
+ Position(double x_, double y_) : x(x_), y(y_) {}
+};
+
+struct Size : public Component<Size> {
+ double width;
+ double height;
+
+ Size(double w, double h) : width(w), height(h) {}
+};
+
+class MovementSystem : public System<MovementSystem>
+{
+public:
+ void update(double dt, EntityManager &em) override
+ {
+ for (auto &&x : em.component_masks_) {
+ if(x[1] == 1) {
+ std::cout << "Found size: ";
+ }
+ }
+ }
+};
+
+int main()
+{
+ EntityManager em;
+ Position p1(1, 2);
+ Position p2(2, 1);
+ Size s1(5, 5);
+ Entity e1 = em.create_entity();
+ Entity e2 = em.create_entity();
+ std::cout << "e1: " << e1 << ", e2: " << e2 << "\n";
+
+ MovementSystem s;
+
+ em.add_component(e1, &p1).add_component(e2, &p2).add_component(e2, &s1);
+
+ s.update(60, em);
+}