summary refs log tree commit diff stats
path: root/src/vector.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-05-10 19:27:59 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-05-17 15:39:39 -0400
commit4bbfeae42a1245b1b84e8847787d7643e6a6f2cf (patch)
tree8dd65d9ab0cfffd0e79f670c94b035c5eebfa934 /src/vector.h
parent67b24a8ddd89371cfb944c5b441c852f0edc23b1 (diff)
downloadtherapy-4bbfeae42a1245b1b84e8847787d7643e6a6f2cf.tar.gz
therapy-4bbfeae42a1245b1b84e8847787d7643e6a6f2cf.tar.bz2
therapy-4bbfeae42a1245b1b84e8847787d7643e6a6f2cf.zip
Started integrating Lua as a scripting engine
Currently moving platforms are able to have their movement controlled by a script rather than by XML, which is probably a better implementation and scales better to other things. The scripts, instead of using the components as state, use the stack as state. In this way, they pretend to be multithreaded. For instance, the moving platform calls moveRight and then moveLeft. Both of those functions internally make calls that say to wait until the next tick. When the AutomatingSystem ticks, it continues execution of all scripts (sequentially, of course) until they ask for the next tick again. This is implemented using coroutines.
Diffstat (limited to 'src/vector.h')
-rw-r--r--src/vector.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/vector.h b/src/vector.h index 3abd98a..9355dd5 100644 --- a/src/vector.h +++ b/src/vector.h
@@ -7,9 +7,11 @@ public:
7 7
8 T coords[2]; 8 T coords[2];
9 9
10 vec2() = default; 10 vec2() : coords{0, 0}
11 {
12 }
11 13
12 vec2(double x, double y) : coords{x, y} 14 vec2(T x, T y) : coords{x, y}
13 { 15 {
14 } 16 }
15 17
@@ -90,12 +92,12 @@ public:
90 return vec2(-x(), -y()); 92 return vec2(-x(), -y());
91 } 93 }
92 94
93 vec2 operator*(double s) const 95 vec2 operator*(T s) const
94 { 96 {
95 return vec2(x() * s, y() * s); 97 return vec2(x() * s, y() * s);
96 } 98 }
97 99
98 vec2& operator*=(double s) 100 vec2& operator*=(T s)
99 { 101 {
100 x() *= s; 102 x() *= s;
101 y() *= s; 103 y() *= s;