From 2ec163612042bfa5e4e1bf220b489506f7039677 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 18 Mar 2015 09:48:43 -0400 Subject: Game can now read map file from map editor (also added new map) --- src/components/map_collision.cpp | 29 +++++++++++++++++++++++++---- src/components/map_collision.h | 3 ++- src/components/map_render.cpp | 1 + src/components/physics_body.cpp | 1 + src/components/player_physics.cpp | 1 + 5 files changed, 30 insertions(+), 5 deletions(-) (limited to 'src/components') diff --git a/src/components/map_collision.cpp b/src/components/map_collision.cpp index 9afa6f8..9adad26 100644 --- a/src/components/map_collision.cpp +++ b/src/components/map_collision.cpp @@ -1,11 +1,14 @@ #include "map_collision.h" #include "map.h" #include "game.h" +#include "consts.h" MapCollisionComponent::MapCollisionComponent(const Map& map) : map(map) { - addCollision(-6, 0, GAME_WIDTH, Direction::left, (map.getLeftMap() == nullptr) ? Collision::Type::wrap : Collision::Type::teleport); - addCollision(GAME_WIDTH+6, 0, GAME_WIDTH, Direction::right, (map.getRightMap() == nullptr) ? Collision::Type::reverse : Collision::Type::teleport); + addCollision(-6, 0, GAME_HEIGHT, Direction::left, collisionFromMoveType(map.getLeftMoveType())); + addCollision(GAME_WIDTH+6, 0, GAME_HEIGHT, Direction::right, collisionFromMoveType(map.getRightMoveType())); + addCollision(-7, 0, GAME_WIDTH, Direction::up, collisionFromMoveType(map.getUpMoveType())); + addCollision(GAME_HEIGHT+6, 0, GAME_WIDTH, Direction::down, collisionFromMoveType(map.getDownMoveType())); for (int i=0; i -class Map; class Game; class MapCollisionComponent : public Component { @@ -35,6 +35,7 @@ class MapCollisionComponent : public Component { 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); + Collision::Type collisionFromMoveType(Map::MoveType type); std::list left_collisions; std::list right_collisions; diff --git a/src/components/map_render.cpp b/src/components/map_render.cpp index 10c5db8..45766e1 100644 --- a/src/components/map_render.cpp +++ b/src/components/map_render.cpp @@ -1,6 +1,7 @@ #include "map_render.h" #include "map.h" #include "game.h" +#include "consts.h" MapRenderComponent::MapRenderComponent(const Map& map) : screen(GAME_WIDTH, GAME_HEIGHT) { diff --git a/src/components/physics_body.cpp b/src/components/physics_body.cpp index 72f2fd8..acbdc5d 100644 --- a/src/components/physics_body.cpp +++ b/src/components/physics_body.cpp @@ -1,5 +1,6 @@ #include "physics_body.h" #include "game.h" +#include "consts.h" void PhysicsBodyComponent::receive(Game&, Entity&, const Message& msg) { diff --git a/src/components/player_physics.cpp b/src/components/player_physics.cpp index e366d6e..1d14f35 100644 --- a/src/components/player_physics.cpp +++ b/src/components/player_physics.cpp @@ -1,6 +1,7 @@ #include "player_physics.h" #include "muxer.h" #include "game.h" +#include "consts.h" #define JUMP_VELOCITY(h, l) (-2 * (h) / (l)) #define JUMP_GRAVITY(h, l) (2 * ((h) / (l)) / (l)) -- cgit 1.4.1