From 6b1dcc5df51df4a2d8b724187eb1bcdb4fd9df8b Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 14 Mar 2015 19:25:23 -0400 Subject: Added sound when you hit the ground Also split up components.cpp into files for each class, fixed a bug concerning falling off the screen when you change maps, and converted collision data into doubles. --- src/components/map_collision.h | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/components/map_collision.h (limited to 'src/components/map_collision.h') diff --git a/src/components/map_collision.h b/src/components/map_collision.h new file mode 100644 index 0000000..3b718b6 --- /dev/null +++ b/src/components/map_collision.h @@ -0,0 +1,46 @@ +#ifndef MAP_COLLISION_H +#define MAP_COLLISION_H + +#include "entity.h" +#include + +class Map; +class Game; + +class MapCollisionComponent : public Component { + public: + MapCollisionComponent(const Map& map); + void detectCollision(Game& game, Entity& entity, Entity& collider, std::pair old_position); + + private: + enum class Direction { + up, left, down, right + }; + + struct Collision { + enum class Type { + wall, + wrap, + teleport, + reverse, + platform, + danger + }; + + double axis; + double lower; + double upper; + Type type; + }; + + void addCollision(double axis, double lower, double upper, Direction dir, Collision::Type type); + void processCollision(Game& game, Entity& collider, Collision collision, Direction dir, std::pair old_position); + + std::list left_collisions; + std::list right_collisions; + std::list up_collisions; + std::list down_collisions; + const Map& map; +}; + +#endif -- cgit 1.4.1