summary refs log tree commit diff stats
path: root/src/systems/mapping.cpp
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/systems/mapping.cpp
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/systems/mapping.cpp')
-rw-r--r--src/systems/mapping.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/systems/mapping.cpp b/src/systems/mapping.cpp index 120a27a..05167c1 100644 --- a/src/systems/mapping.cpp +++ b/src/systems/mapping.cpp
@@ -93,6 +93,34 @@ void MappingSystem::loadMap(size_t mapId)
93 93
94 const Map& map = game_.getWorld().getMap(mappable.getMapId()); 94 const Map& map = game_.getWorld().getMap(mappable.getMapId());
95 95
96 addBoundary(
97 mappable.getLeftBoundaries(),
98 -WALL_GAP,
99 0,
100 MAP_HEIGHT * TILE_HEIGHT,
101 MappableComponent::Boundary::Type::adjacency);
102
103 addBoundary(
104 mappable.getRightBoundaries(),
105 GAME_WIDTH + WALL_GAP,
106 0,
107 MAP_HEIGHT * TILE_HEIGHT,
108 MappableComponent::Boundary::Type::adjacency);
109
110 addBoundary(
111 mappable.getUpBoundaries(),
112 -WALL_GAP,
113 0,
114 GAME_WIDTH,
115 MappableComponent::Boundary::Type::adjacency);
116
117 addBoundary(
118 mappable.getDownBoundaries(),
119 MAP_HEIGHT * TILE_HEIGHT + WALL_GAP,
120 0,
121 GAME_WIDTH,
122 MappableComponent::Boundary::Type::adjacency);
123
96 for (size_t i = 0; i < MAP_WIDTH * MAP_HEIGHT; i++) 124 for (size_t i = 0; i < MAP_WIDTH * MAP_HEIGHT; i++)
97 { 125 {
98 size_t x = i % MAP_WIDTH; 126 size_t x = i % MAP_WIDTH;