summary refs log tree commit diff stats
path: root/src/systems/pondering.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-04-29 16:45:55 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-04-29 16:45:55 -0400
commitc00668c58b26325203cb6815bc3dedf1e7d7ac5e (patch)
treef03d9b420779f365a51285c9a2b675a5e7e965c5 /src/systems/pondering.h
parent36cceabfc5ddd22d9ae0d6c4dee9d4041bf2e348 (diff)
downloadtherapy-c00668c58b26325203cb6815bc3dedf1e7d7ac5e.tar.gz
therapy-c00668c58b26325203cb6815bc3dedf1e7d7ac5e.tar.bz2
therapy-c00668c58b26325203cb6815bc3dedf1e7d7ac5e.zip
Added map object collision
Collision checking in PonderingSystem was rewritten to work as follows: horizontal movement is step first, then vertical. In each step, the closest environmental boundary to the body is found on the axis of movement in the space traversed by the body. Then, if any map objects fall in the region between the body's old position and the environmental boundary (or body new position if no boundary was found), process collision with those bodies in increasing distance order, stopping if a collision stops movement short of where the next collision would take place. After this, process collision with all of the environmental boundaries at the axis distance found earlier, as long as movement hasn't stopped short.

This is not the most optimal implementation, and there is a lot of code repetition, but it is a start and it works.

All map objects currently function as walls.

This fixes the bug where you could, with pixel-perfect precision, jump into the corner of a wall tile.

The top of the hitbox for the spike tile was lowered by one pixel. This fixes a problem where if the player is halfway on a floor tile and halfway over a spike tile, the floor tile would not stop the spike tile from being processed, and the player would die.
Diffstat (limited to 'src/systems/pondering.h')
-rw-r--r--src/systems/pondering.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/systems/pondering.h b/src/systems/pondering.h index 58e6496..aa430db 100644 --- a/src/systems/pondering.h +++ b/src/systems/pondering.h
@@ -18,6 +18,29 @@ public:
18 18
19 void initPrototype(id_type prototype); 19 void initPrototype(id_type prototype);
20 20
21private:
22
23 struct CollisionResult
24 {
25 double newX;
26 double newY;
27 bool stopProcessing = false;
28 bool touchedWall = false;
29 bool adjacentlyWarping = false;
30 Direction adjWarpDir;
31 size_t adjWarpMapId;
32 };
33
34 void processCollision(
35 id_type entity,
36 id_type collider,
37 Direction dir,
38 PonderableComponent::Collision type,
39 double axis,
40 double lower,
41 double upper,
42 CollisionResult& result);
43
21}; 44};
22 45
23#endif /* end of include guard: PONDERING_H_F2530E0E */ 46#endif /* end of include guard: PONDERING_H_F2530E0E */