]> git.localhorst.tv Git - l2e.git/commitdiff
added map transition state
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 7 Oct 2012 14:15:50 +0000 (16:15 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 7 Oct 2012 14:15:50 +0000 (16:15 +0200)
Debug/src/map/subdir.mk
Release/src/map/subdir.mk
src/map/MapState.cpp
src/map/MapState.h
src/map/TransitionState.cpp [new file with mode: 0644]
src/map/TransitionState.h [new file with mode: 0644]
src/map/fwd.h

index 01eb7874622884488b6a347cbeb7d03601246b2b..5faffc5ac2d334f35313803c750df218cf181331 100644 (file)
@@ -9,6 +9,7 @@ CPP_SRCS += \
 ../src/map/Map.cpp \
 ../src/map/MapState.cpp \
 ../src/map/Tile.cpp \
+../src/map/TransitionState.cpp \
 ../src/map/Trigger.cpp 
 
 OBJS += \
@@ -17,6 +18,7 @@ OBJS += \
 ./src/map/Map.o \
 ./src/map/MapState.o \
 ./src/map/Tile.o \
+./src/map/TransitionState.o \
 ./src/map/Trigger.o 
 
 CPP_DEPS += \
@@ -25,6 +27,7 @@ CPP_DEPS += \
 ./src/map/Map.d \
 ./src/map/MapState.d \
 ./src/map/Tile.d \
+./src/map/TransitionState.d \
 ./src/map/Trigger.d 
 
 
index cf8c41a545ae9cd1434df592052ccdb6f901c330..78e65f369afbf50073dc136e2c3a164751c4377f 100644 (file)
@@ -9,6 +9,7 @@ CPP_SRCS += \
 ../src/map/Map.cpp \
 ../src/map/MapState.cpp \
 ../src/map/Tile.cpp \
+../src/map/TransitionState.cpp \
 ../src/map/Trigger.cpp 
 
 OBJS += \
@@ -17,6 +18,7 @@ OBJS += \
 ./src/map/Map.o \
 ./src/map/MapState.o \
 ./src/map/Tile.o \
+./src/map/TransitionState.o \
 ./src/map/Trigger.o 
 
 CPP_DEPS += \
@@ -25,6 +27,7 @@ CPP_DEPS += \
 ./src/map/Map.d \
 ./src/map/MapState.d \
 ./src/map/Tile.d \
+./src/map/TransitionState.d \
 ./src/map/Trigger.d 
 
 
index 791cc0bb319373ccceaaba6a7ae70b5d4fdda211..64c254786559bb2fce4958005c1dde5de85d8bd9 100644 (file)
@@ -9,20 +9,24 @@
 
 #include "Map.h"
 #include "Tile.h"
+#include "TransitionState.h"
 #include "Trigger.h"
 #include "../app/Application.h"
 #include "../app/Input.h"
+#include "../graphics/ColorFade.h"
 
 #include <algorithm>
 
 using app::Application;
 using app::Input;
 using geometry::Vector;
+using graphics::ColorFade;
 
 namespace map {
 
 MapState::MapState(Map *map)
-: map(map)
+: ctrl(0)
+, map(map)
 , controlled(0)
 , tempTarget(20, 20)
 , camera(100, 100, &tempTarget)
@@ -35,7 +39,8 @@ MapState::MapState(Map *map)
 }
 
 
-void MapState::EnterState(Application &ctrl, SDL_Surface *screen) {
+void MapState::EnterState(Application &c, SDL_Surface *screen) {
+       ctrl = &c;
        camera.Resize(screen->w, screen->h);
        LoadMap(map);
 }
@@ -235,7 +240,9 @@ void MapState::CheckTrigger() {
        if (trigger) {
                // TODO: run trigger script
                if (trigger->map) {
-                       Transition(trigger->map, trigger->target);
+                       ctrl->PushState(new ColorFade(this, 0, 500, true));
+                       ctrl->PushState(new TransitionState(this, trigger->map, trigger->target));
+                       ctrl->PushState(new ColorFade(this, 0, 500, false));
                }
        }
 
index 0e49100e3b305b6e458123af8060986fd4b76958..dc352f69522636e5f2248076f6cddb59bea2a804 100644 (file)
@@ -64,6 +64,7 @@ private:
        void CheckTrigger();
 
 private:
+       app::Application *ctrl;
        Map *map;
        Entity *controlled;
        app::Timer<float> moveTimer;
diff --git a/src/map/TransitionState.cpp b/src/map/TransitionState.cpp
new file mode 100644 (file)
index 0000000..9a1d699
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * TransitionState.cpp
+ *
+ *  Created on: Oct 7, 2012
+ *      Author: holy
+ */
+
+#include "TransitionState.h"
+
+#include "MapState.h"
+#include "../app/Application.h"
+
+using app::Application;
+using app::State;
+using app::Input;
+using geometry::Vector;
+
+namespace map {
+
+TransitionState::TransitionState(MapState *ms, Map *map, const Vector<int> &coordinates)
+: ctrl(0)
+, ms(ms)
+, map(map)
+, coordinates(coordinates) {
+
+}
+
+void TransitionState::EnterState(Application &c, SDL_Surface *screen) {
+       ctrl = &c;
+}
+
+void TransitionState::ExitState(Application &, SDL_Surface *screen) {
+
+}
+
+void TransitionState::ResumeState(Application &ctrl, SDL_Surface *screen) {
+
+}
+
+void TransitionState::PauseState(Application &ctrl, SDL_Surface *screen) {
+
+}
+
+
+void TransitionState::Resize(int width, int height) {
+
+}
+
+
+void TransitionState::HandleEvents(const Input &input) {
+       ms->Transition(map, coordinates);
+       ctrl->PopState();
+}
+
+
+void TransitionState::UpdateWorld(float deltaT) {
+
+}
+
+void TransitionState::Render(SDL_Surface *screen) {
+//     ms->Render(screen);
+}
+
+}
diff --git a/src/map/TransitionState.h b/src/map/TransitionState.h
new file mode 100644 (file)
index 0000000..ee832a8
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * TransitionState.h
+ *
+ *  Created on: Oct 7, 2012
+ *      Author: holy
+ */
+
+#ifndef MAP_TRANSITIONSTATE_H_
+#define MAP_TRANSITIONSTATE_H_
+
+#include "fwd.h"
+#include "../app/State.h"
+#include "../geometry/Vector.h"
+
+namespace map {
+
+class TransitionState
+: public app::State {
+
+public:
+       TransitionState(MapState *, Map *, const geometry::Vector<int> &);
+       virtual ~TransitionState() { }
+
+public:
+       virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
+       virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
+       virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
+       virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+
+       virtual void Resize(int width, int height);
+
+       virtual void HandleEvents(const app::Input &);
+       virtual void UpdateWorld(float deltaT);
+       virtual void Render(SDL_Surface *);
+
+private:
+       app::Application *ctrl;
+       MapState *ms;
+       Map *map;
+       const geometry::Vector<int> &coordinates;
+
+};
+
+}
+
+#endif /* MAP_TRANSITIONSTATE_H_ */
index 8f2603c9504fc91521c869611786246ded572942..464bb6fdab4645879bd76f7fcbe964d4ced3036d 100644 (file)
@@ -15,6 +15,7 @@ class Entity;
 class Map;
 class MapState;
 class Tile;
+class TransitionState;
 class Trigger;
 
 }