From: Daniel Karbach Date: Fri, 12 Oct 2012 18:55:03 +0000 (+0200) Subject: made targetless camera possible X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;h=978ccdf2644bc445c864dbe581ead365b238cff8;p=l2e.git made targetless camera possible also removed target dummy of map state which is no longer needed --- 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;