From: Daniel Karbach Date: Sat, 29 Sep 2012 19:01:54 +0000 (+0200) Subject: added application state for map X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=dc7b19b8d0be4aff410f9c4514c742fe28b25ff4;p=l2e.git added application state for map --- diff --git a/Debug/src/map/subdir.mk b/Debug/src/map/subdir.mk index 5f0138c..b90f2b1 100644 --- a/Debug/src/map/subdir.mk +++ b/Debug/src/map/subdir.mk @@ -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/Release/src/map/subdir.mk b/Release/src/map/subdir.mk index 384a876..7fa8f6a 100644 --- a/Release/src/map/subdir.mk +++ b/Release/src/map/subdir.mk @@ -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 index 0000000..ed77648 --- /dev/null +++ b/src/map/MapState.cpp @@ -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 offset(camera.CalculateOffset()); + map->Render(screen, offset); +} + +} diff --git a/src/map/MapState.h b/src/map/MapState.h new file mode 100644 index 0000000..96a5c22 --- /dev/null +++ b/src/map/MapState.h @@ -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 tempTarget; + graphics::Camera camera; + +}; + +} + +#endif /* MAP_MAPSTATE_H_ */ diff --git a/src/map/fwd.h b/src/map/fwd.h index 7ffe7a2..5ff828b 100644 --- a/src/map/fwd.h +++ b/src/map/fwd.h @@ -12,6 +12,7 @@ namespace map { class Area; class Map; +class MapState; class Tile; }