From e16fb5be90c889c371cbb0ca2444735c2e12073c Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 18 Feb 2018 12:35:45 -0500 Subject: 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. --- src/components/mappable.h | 10 ++-------- src/components/playable.h | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 src/components/playable.h (limited to 'src/components') 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 @@ #include #include "component.h" #include "renderer/texture.h" +#include "collision.h" #include "map.h" class MappableComponent : public Component { @@ -12,14 +13,7 @@ public: class Boundary { public: - enum class Type { - wall, - wrap, - teleport, - reverse, - platform, - danger - }; + using Type = Collision::Type; Boundary( 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 @@ +#ifndef PLAYABLE_H_DDC566C3 +#define PLAYABLE_H_DDC566C3 + +#include "component.h" + +class PlayableComponent : public Component { +public: + + bool changingMap = false; + int newMapId = -1; + double newMapX = 0; + double newMapY = 0; +}; + +#endif /* end of include guard: PLAYABLE_H_DDC566C3 */ -- cgit 1.4.1