]> code.bitgloo.com Git - clyne/gamedev2.git/commitdiff
Added IdleFunc components to entities, this will be assigned to all entities no matte...
authorAndy <drumsetmonkey@gmail.com>
Fri, 30 Aug 2019 15:01:15 +0000 (11:01 -0400)
committerAndy <drumsetmonkey@gmail.com>
Fri, 30 Aug 2019 15:01:15 +0000 (11:01 -0400)
Scripts/init.lua
src/components/IdleFunc.hpp [new file with mode: 0644]
src/components/Position.hpp
src/script.cpp

index 3ec46185a08144d31b33d3f20dcf00e88a1d4b7d..851c1806b636fd204360bdfba04454addb192025 100644 (file)
@@ -1,15 +1,3 @@
---Player = entityx.manager:new()
---function Player:init(o)
---    o = o or {}
---    self.position = self:component("Position", o.position or {0, 0})
---end
---
---p = Player:instance({position = {10, 20}})
---p.position.x(5)
---print(p.position.x(), p.position.y())
-
---p = comp:Position(6.5, 2.3)
-
 bird = {
     Position = {
         x = 1.2,
diff --git a/src/components/IdleFunc.hpp b/src/components/IdleFunc.hpp
new file mode 100644 (file)
index 0000000..29bcd7b
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2019  Belle-Isle, Andrew <drumsetmonkey@gmail.com>
+ * Author: Belle-Isle, Andrew <drumsetmonkey@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDLEFUNC_HPP_
+#define IDLEFUNC_HPP_
+
+#include <components/Component.hpp>
+
+struct IdleFunc : Component<IdleFunc>, entityx::Component<IdleFunc>
+{
+    sol::function luafunc;
+    public:
+        IdleFunc() {}
+
+        IdleFunc FromLua(sol::object ref)
+        {
+            if (ref.get_type() == sol::type::function) {
+                this->luafunc = ref;
+            }
+            return *this;
+        }
+};
+
+#endif//IDLEFUNC_HPP_
index 1c6cf714db7700a6b48cc66a9bb792631d2dae4b..0d693931b26395db949f3d8aa71da6e632cb3e6b 100644 (file)
@@ -23,7 +23,6 @@
 
 struct Position : Component<Position>, entityx::Component<Position>
 {
-    
     public:
         float x,y;
         Position(float _x, float _y): x(_x), y(_y) {}
index 86917b9494126bee6967ff19831699238c693ec6..bb413fee04e9597db8dfd5b93b202cecb23aa101 100644 (file)
@@ -66,6 +66,7 @@ int ScriptSystem::init(void)
 #include <components/Position.hpp>
 #include <components/Name.hpp>
 #include <components/Render.hpp>
+#include <components/IdleFunc.hpp>
 
 void ScriptSystem::doFile(void)
 {