summary refs log tree commit diff stats
path: root/src/components
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-02-18 12:35:45 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-02-18 12:35:45 -0500
commite16fb5be90c889c371cbb0ca2444735c2e12073c (patch)
treecbaa20e14a34c460b6c9886f266c4b4b6f62ae87 /src/components
parented08b673c50b076042d8f0c49501372168142764 (diff)
downloadtherapy-e16fb5be90c889c371cbb0ca2444735c2e12073c.tar.gz
therapy-e16fb5be90c889c371cbb0ca2444735c2e12073c.tar.bz2
therapy-e16fb5be90c889c371cbb0ca2444735c2e12073c.zip
Implemented map adjacency
This brings along with it the ability to move to different maps, for which the PlayingSystem and PlayableComponent were introduced. The PlayingSystem is a general overseer system that handles big picture stuff like initializing the player and changing maps. The PlayableComponent represents the player. While the ControllableComponent is also likely to always only be on the player entity, the two are distinct by separation of concerns.

This also required a refactoring of how collisions are processed, because of a bug where the player can move to a new map when horizontal collisions are checked, and vertical collisions are skipped, causing the player to clip through the ground because the normal force was never handled.
Diffstat (limited to 'src/components')
-rw-r--r--src/components/mappable.h10
-rw-r--r--src/components/playable.h15
2 files changed, 17 insertions, 8 deletions
diff --git a/src/components/mappable.h b/src/components/mappable.h index 2dbab77..633cdf4 100644 --- a/src/components/mappable.h +++ b/src/components/mappable.h
@@ -4,6 +4,7 @@
4#include <map> 4#include <map>
5#include "component.h" 5#include "component.h"
6#include "renderer/texture.h" 6#include "renderer/texture.h"
7#include "collision.h"
7#include "map.h" 8#include "map.h"
8 9
9class MappableComponent : public Component { 10class MappableComponent : public Component {
@@ -12,14 +13,7 @@ public:
12 class Boundary { 13 class Boundary {
13 public: 14 public:
14 15
15 enum class Type { 16 using Type = Collision::Type;
16 wall,
17 wrap,
18 teleport,
19 reverse,
20 platform,
21 danger
22 };
23 17
24 Boundary( 18 Boundary(
25 double axis, 19 double axis,
diff --git a/src/components/playable.h b/src/components/playable.h new file mode 100644 index 0000000..a6e71b0 --- /dev/null +++ b/src/components/playable.h
@@ -0,0 +1,15 @@
1#ifndef PLAYABLE_H_DDC566C3
2#define PLAYABLE_H_DDC566C3
3
4#include "component.h"
5
6class PlayableComponent : public Component {
7public:
8
9 bool changingMap = false;
10 int newMapId = -1;
11 double newMapX = 0;
12 double newMapY = 0;
13};
14
15#endif /* end of include guard: PLAYABLE_H_DDC566C3 */