]> git.localhorst.tv Git - l2e.git/commitdiff
made targetless camera possible
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 12 Oct 2012 18:55:03 +0000 (20:55 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 12 Oct 2012 18:55:03 +0000 (20:55 +0200)
also removed target dummy of map state which is no longer needed

src/graphics/Camera.cpp
src/map/MapState.cpp
src/map/MapState.h

index a0773db821ca1a14a0ec6fafa066f7533cda8d1a..e882eb19a322f32231f501d286f24109edb397fd 100644 (file)
@@ -15,20 +15,23 @@ namespace graphics {
 
 Camera::Camera(int width, int height, const Vector<float> *target)
 : target(target), halfWidth(width / 2), halfHeight(height / 2) {
-       assert(target && "construct camera without target");
+
 }
 
 
 void Camera::SetTarget(const Vector<float> *t) {
-       assert(t && "cannot change camera target to 0");
        target = t;
 }
 
 
 Vector<int> Camera::CalculateOffset() const {
-       return Vector<int>(
-                       (target->X() - halfWidth) * -1,
-                       (target->Y() - halfHeight) * -1);
+       if (target) {
+               return Vector<int>(
+                               (target->X() - halfWidth) * -1,
+                               (target->Y() - halfHeight) * -1);
+       } else {
+               return Vector<int>();
+       }
 }
 
 }
index d50cda65bfa782e1ee4a0a485c29e89676e8ed71..e1b3e1f95030d7074ab91067a38d9ba94b7f0983 100644 (file)
@@ -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)
index c565632569a766552ee4c693d6b8f963eea23f15..0ca5a847a5805ef37881ac2c519cc717720d6449 100644 (file)
@@ -72,7 +72,6 @@ private:
        Entity *controlled;
        Entity *pushed;
        app::Timer<float> moveTimer;
-       geometry::Vector<float> tempTarget;
        geometry::Vector<int> lastLock;
        graphics::Camera camera;
        std::vector<Entity *> entities;