]> git.localhorst.tv Git - l2e.git/commitdiff
added application state for map
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 29 Sep 2012 19:01:54 +0000 (21:01 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 29 Sep 2012 19:01:54 +0000 (21:01 +0200)
Debug/src/map/subdir.mk
Release/src/map/subdir.mk
src/map/MapState.cpp [new file with mode: 0644]
src/map/MapState.h [new file with mode: 0644]
src/map/fwd.h

index 5f0138cd2f28b4866353113a406086b5b4a76966..b90f2b1f7e1bf0b53f03d76eaff0991dd0a4c5ce 100644 (file)
@@ -6,16 +6,19 @@
 CPP_SRCS += \
 ../src/map/Area.cpp \
 ../src/map/Map.cpp \
+../src/map/MapState.cpp \
 ../src/map/Tile.cpp 
 
 OBJS += \
 ./src/map/Area.o \
 ./src/map/Map.o \
+./src/map/MapState.o \
 ./src/map/Tile.o 
 
 CPP_DEPS += \
 ./src/map/Area.d \
 ./src/map/Map.d \
+./src/map/MapState.d \
 ./src/map/Tile.d 
 
 
index 384a8761e071d2a79b550c73c9e3d6c2f929ced8..7fa8f6a276b862199c39190894e0c6bbab773a1f 100644 (file)
@@ -6,16 +6,19 @@
 CPP_SRCS += \
 ../src/map/Area.cpp \
 ../src/map/Map.cpp \
+../src/map/MapState.cpp \
 ../src/map/Tile.cpp 
 
 OBJS += \
 ./src/map/Area.o \
 ./src/map/Map.o \
+./src/map/MapState.o \
 ./src/map/Tile.o 
 
 CPP_DEPS += \
 ./src/map/Area.d \
 ./src/map/Map.d \
+./src/map/MapState.d \
 ./src/map/Tile.d 
 
 
diff --git a/src/map/MapState.cpp b/src/map/MapState.cpp
new file mode 100644 (file)
index 0000000..ed77648
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * MapState.cpp
+ *
+ *  Created on: Sep 29, 2012
+ *      Author: holy
+ */
+
+#include "MapState.h"
+
+#include "Map.h"
+#include "../app/Application.h"
+#include "../app/Input.h"
+
+using app::Application;
+using app::Input;
+using geometry::Vector;
+
+namespace map {
+
+MapState::MapState(const Map *map)
+: map(map)
+, tempTarget(20, 20)
+, camera(100, 100, &tempTarget) {
+
+}
+
+
+void MapState::EnterState(Application &ctrl, SDL_Surface *screen) {
+       camera.Resize(screen->w, screen->h);
+}
+
+void MapState::ExitState(Application &ctrl, SDL_Surface *screen) {
+
+}
+
+void MapState::ResumeState(Application &ctrl, SDL_Surface *screen) {
+       camera.Resize(screen->w, screen->h);
+}
+
+void MapState::PauseState(Application &ctrl, SDL_Surface *screen) {
+
+}
+
+void MapState::Resize(int width, int height) {
+       camera.Resize(width, height);
+}
+
+
+void MapState::HandleEvents(const Input &input) {
+
+}
+
+void MapState::UpdateWorld(float deltaT) {
+
+}
+
+void MapState::Render(SDL_Surface *screen) {
+       Vector<int> offset(camera.CalculateOffset());
+       map->Render(screen, offset);
+}
+
+}
diff --git a/src/map/MapState.h b/src/map/MapState.h
new file mode 100644 (file)
index 0000000..96a5c22
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * MapState.h
+ *
+ *  Created on: Sep 29, 2012
+ *      Author: holy
+ */
+
+#ifndef MAP_MAPSTATE_H_
+#define MAP_MAPSTATE_H_
+
+#include "fwd.h"
+#include "../app/State.h"
+#include "../geometry/Vector.h"
+#include "../graphics/Camera.h"
+
+namespace map {
+
+class MapState
+: public app::State {
+
+public:
+       explicit MapState(const Map *);
+       virtual ~MapState() { }
+
+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:
+       const Map *map;
+       geometry::Vector<int> tempTarget;
+       graphics::Camera camera;
+
+};
+
+}
+
+#endif /* MAP_MAPSTATE_H_ */
index 7ffe7a29127eb837fb5bd6924634206a9e48f314..5ff828b886508d968a3c80f3b22cde38f6a0f2ea 100644 (file)
@@ -12,6 +12,7 @@ namespace map {
 
 class Area;
 class Map;
+class MapState;
 class Tile;
 
 }