From 978ccdf2644bc445c864dbe581ead365b238cff8 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Fri, 12 Oct 2012 20:55:03 +0200 Subject: [PATCH] made targetless camera possible also removed target dummy of map state which is no longer needed --- src/graphics/Camera.cpp | 13 ++++++++----- src/map/MapState.cpp | 3 +-- src/map/MapState.h | 1 - 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/graphics/Camera.cpp b/src/graphics/Camera.cpp index a0773db..e882eb1 100644 --- a/src/graphics/Camera.cpp +++ b/src/graphics/Camera.cpp @@ -15,20 +15,23 @@ namespace graphics { Camera::Camera(int width, int height, const Vector *target) : target(target), halfWidth(width / 2), halfHeight(height / 2) { - assert(target && "construct camera without target"); + } void Camera::SetTarget(const Vector *t) { - assert(t && "cannot change camera target to 0"); target = t; } Vector Camera::CalculateOffset() const { - return Vector( - (target->X() - halfWidth) * -1, - (target->Y() - halfHeight) * -1); + if (target) { + return Vector( + (target->X() - halfWidth) * -1, + (target->Y() - halfHeight) * -1); + } else { + return Vector(); + } } } diff --git a/src/map/MapState.cpp b/src/map/MapState.cpp index d50cda6..e1b3e1f 100644 --- a/src/map/MapState.cpp +++ b/src/map/MapState.cpp @@ -35,8 +35,7 @@ MapState::MapState(GameConfig *g, Map *map) , map(map) , controlled(0) , pushed(0) -, tempTarget(20, 20) -, camera(100, 100, &tempTarget) +, camera(100, 100, 0) , walkingSpeed(64) , nextDirection(-1) , afterLock(false) diff --git a/src/map/MapState.h b/src/map/MapState.h index c565632..0ca5a84 100644 --- a/src/map/MapState.h +++ b/src/map/MapState.h @@ -72,7 +72,6 @@ private: Entity *controlled; Entity *pushed; app::Timer moveTimer; - geometry::Vector tempTarget; geometry::Vector lastLock; graphics::Camera camera; std::vector entities; -- 2.39.2