summary refs log tree commit diff stats
path: root/src/components
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-05-08 21:09:36 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-05-09 17:59:13 -0400
commit5c82f052c26303318e81ddd76475c1d188cc74f4 (patch)
tree3204ef94f2861224a380aa566728c02b4acd1fd9 /src/components
parent96e6f3231aed9919d660a06944f1d96dc8241f8e (diff)
downloadtherapy-5c82f052c26303318e81ddd76475c1d188cc74f4.tar.gz
therapy-5c82f052c26303318e81ddd76475c1d188cc74f4.tar.bz2
therapy-5c82f052c26303318e81ddd76475c1d188cc74f4.zip
Simplified positions/sizes with vectors
Positions and sizes are now stored as vectors (of doubles and ints, respectively). This allows for at least minor code simplification in many places, and cleans up the CollisionParams code in PonderingSystem quite a bit.
Diffstat (limited to 'src/components')
-rw-r--r--src/components/automatable.h4
-rw-r--r--src/components/playable.h4
-rw-r--r--src/components/ponderable.h10
-rw-r--r--src/components/realizable.h4
-rw-r--r--src/components/transformable.h13
5 files changed, 15 insertions, 20 deletions
diff --git a/src/components/automatable.h b/src/components/automatable.h index b37945f..c1fd1a3 100644 --- a/src/components/automatable.h +++ b/src/components/automatable.h
@@ -4,6 +4,7 @@
4#include "component.h" 4#include "component.h"
5#include <vector> 5#include <vector>
6#include <random> 6#include <random>
7#include "vector.h"
7 8
8class AutomatableComponent : public Component { 9class AutomatableComponent : public Component {
9public: 10public:
@@ -18,8 +19,7 @@ public:
18 * The horizontal and vertical speed, in pixels/sec, that the entity should 19 * The horizontal and vertical speed, in pixels/sec, that the entity should
19 * move at. 20 * move at.
20 */ 21 */
21 double speedX; 22 vec2d speed;
22 double speedY;
23 23
24 /** 24 /**
25 * The duration of the action in seconds. 25 * The duration of the action in seconds.
diff --git a/src/components/playable.h b/src/components/playable.h index 94d4326..b8af0f2 100644 --- a/src/components/playable.h +++ b/src/components/playable.h
@@ -3,6 +3,7 @@
3 3
4#include "component.h" 4#include "component.h"
5#include "entity_manager.h" 5#include "entity_manager.h"
6#include "vector.h"
6 7
7class PlayableComponent : public Component { 8class PlayableComponent : public Component {
8public: 9public:
@@ -24,8 +25,7 @@ public:
24 * @managed_by PlayingSystem 25 * @managed_by PlayingSystem
25 */ 26 */
26 size_t checkpointMapId; 27 size_t checkpointMapId;
27 double checkpointX; 28 vec2d checkpointPos;
28 double checkpointY;
29 29
30}; 30};
31 31
diff --git a/src/components/ponderable.h b/src/components/ponderable.h index eff20e9..c0312b4 100644 --- a/src/components/ponderable.h +++ b/src/components/ponderable.h
@@ -4,6 +4,7 @@
4#include <set> 4#include <set>
5#include "component.h" 5#include "component.h"
6#include "entity_manager.h" 6#include "entity_manager.h"
7#include "vector.h"
7 8
8class PonderableComponent : public Component { 9class PonderableComponent : public Component {
9public: 10public:
@@ -45,14 +46,12 @@ public:
45 /** 46 /**
46 * The velocity of the body. 47 * The velocity of the body.
47 */ 48 */
48 double velX = 0.0; 49 vec2d vel = { 0.0, 0.0 };
49 double velY = 0.0;
50 50
51 /** 51 /**
52 * The acceleration of the body. 52 * The acceleration of the body.
53 */ 53 */
54 double accelX = 0.0; 54 vec2d accel = { 0.0, 0.0 };
55 double accelY = 0.0;
56 55
57 /** 56 /**
58 * The type of physical body that the entity is meant to assume. The body will 57 * The type of physical body that the entity is meant to assume. The body will
@@ -89,8 +88,7 @@ public:
89 * 88 *
90 * @managed_by PonderingSystem 89 * @managed_by PonderingSystem
91 */ 90 */
92 double relX; 91 vec2d rel = { 0.0, 0.0 };
93 double relY;
94 92
95 /** 93 /**
96 * The bodies that are being ferried by this body. 94 * The bodies that are being ferried by this body.
diff --git a/src/components/realizable.h b/src/components/realizable.h index 0858e7a..b749aeb 100644 --- a/src/components/realizable.h +++ b/src/components/realizable.h
@@ -5,6 +5,7 @@
5#include <set> 5#include <set>
6#include <map> 6#include <map>
7#include "entity_manager.h" 7#include "entity_manager.h"
8#include "vector.h"
8 9
9class RealizableComponent : public Component { 10class RealizableComponent : public Component {
10public: 11public:
@@ -31,8 +32,7 @@ public:
31 * @managed_by RealizingSystem 32 * @managed_by RealizingSystem
32 */ 33 */
33 int startingMapId; 34 int startingMapId;
34 int startingX; 35 vec2i startingPos;
35 int startingY;
36 36
37 /** 37 /**
38 * The set of map entities loaded by this entity. It is only intended for 38 * The set of map entities loaded by this entity. It is only intended for
diff --git a/src/components/transformable.h b/src/components/transformable.h index 6f3c2ef..bb21996 100644 --- a/src/components/transformable.h +++ b/src/components/transformable.h
@@ -2,6 +2,7 @@
2#define LOCATABLE_H_39E526CA 2#define LOCATABLE_H_39E526CA
3 3
4#include "component.h" 4#include "component.h"
5#include "vector.h"
5 6
6class TransformableComponent : public Component { 7class TransformableComponent : public Component {
7public: 8public:
@@ -15,24 +16,20 @@ public:
15 * so, use PonderingSystem::unferry on the body to ensure that it is not 16 * so, use PonderingSystem::unferry on the body to ensure that it is not
16 * ferried. 17 * ferried.
17 */ 18 */
18 double x; 19 vec2d pos;
19 double y;
20 20
21 /** 21 /**
22 * The size of the entity. 22 * The size of the entity.
23 */ 23 */
24 int w; 24 vec2i size;
25 int h;
26 25
27 /** 26 /**
28 * For prototypes, the original coordinates and size of the entity. 27 * For prototypes, the original coordinates and size of the entity.
29 * 28 *
30 * @managed_by RealizingSystem 29 * @managed_by RealizingSystem
31 */ 30 */
32 double origX; 31 vec2d origPos;
33 double origY; 32 vec2i origSize;
34 int origW;
35 int origH;
36}; 33};
37 34
38#endif /* end of include guard: LOCATABLE_H_39E526CA */ 35#endif /* end of include guard: LOCATABLE_H_39E526CA */