]> git.localhorst.tv Git - l2e.git/commitdiff
added empty battle state
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 5 Aug 2012 14:08:30 +0000 (16:08 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 5 Aug 2012 14:08:30 +0000 (16:08 +0200)
Debug/src/battle/subdir.mk
Release/src/battle/subdir.mk
src/battle/BattleState.cpp [new file with mode: 0644]
src/battle/BattleState.h [new file with mode: 0644]
src/main.cpp

index 37e416128b77c03e6eb1e5d14ce49cc01ecd505e..6cc1a8f15db610e49a9e942448cc58291ad24ee3 100644 (file)
@@ -4,12 +4,15 @@
 
 # Add inputs and outputs from these tool invocations to the build variables 
 CPP_SRCS += \
+../src/battle/BattleState.cpp \
 ../src/battle/Monster.cpp 
 
 OBJS += \
+./src/battle/BattleState.o \
 ./src/battle/Monster.o 
 
 CPP_DEPS += \
+./src/battle/BattleState.d \
 ./src/battle/Monster.d 
 
 
index 213b6f06ad5803aa9a1c76cf310625467a9c1064..c2080a7ded4f7eff26a3f08fa2e1101f9df4e8a3 100644 (file)
@@ -4,12 +4,15 @@
 
 # Add inputs and outputs from these tool invocations to the build variables 
 CPP_SRCS += \
+../src/battle/BattleState.cpp \
 ../src/battle/Monster.cpp 
 
 OBJS += \
+./src/battle/BattleState.o \
 ./src/battle/Monster.o 
 
 CPP_DEPS += \
+./src/battle/BattleState.d \
 ./src/battle/Monster.d 
 
 
diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp
new file mode 100644 (file)
index 0000000..25fb09c
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * BattleState.cpp
+ *
+ *  Created on: Aug 5, 2012
+ *      Author: holy
+ */
+
+#include "BattleState.h"
+
+using app::Application;
+
+namespace battle {
+
+void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) {
+
+}
+
+void BattleState::ExitState() {
+
+}
+
+
+void BattleState::HandleEvent(const SDL_Event &) {
+
+}
+
+void BattleState::UpdateWorld(float deltaT) {
+
+}
+
+void BattleState::Render(SDL_Surface *screen) {
+       // TODO: center background if screen bigger
+       SDL_BlitSurface(background, 0, screen, 0);
+}
+
+}
diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h
new file mode 100644 (file)
index 0000000..b88bae3
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * BattleState.h
+ *
+ *  Created on: Aug 5, 2012
+ *      Author: holy
+ */
+
+#ifndef BATTLE_BATTLESTATE_H_
+#define BATTLE_BATTLESTATE_H_
+
+#include "Monster.h"
+#include "../app/State.h"
+
+#include <vector>
+#include <SDL.h>
+
+namespace battle {
+
+class BattleState
+: public app::State {
+
+public:
+       explicit BattleState(SDL_Surface *background)
+       : background(background) { }
+
+public:
+       virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
+       virtual void ExitState();
+
+       virtual void HandleEvent(const SDL_Event &);
+       virtual void UpdateWorld(float deltaT);
+       virtual void Render(SDL_Surface *);
+
+private:
+       SDL_Surface *background;
+       std::vector<Monster> monsters;
+
+};
+
+}
+
+#endif /* BATTLE_BATTLESTATE_H_ */
index 2040663eba42195dd402a2aa0f5034d127ba5c1c..780b8c27b70c85e004d77d45e0a1a3b6e8358971 100644 (file)
@@ -5,12 +5,16 @@
  *      Author: holy
  */
 
+#include "app/Application.h"
+#include "battle/BattleState.h"
 #include "sdl/InitScreen.h"
 #include "sdl/InitSDL.h"
 
 #include <exception>
 #include <iostream>
 
+using app::Application;
+using battle::BattleState;
 using sdl::InitScreen;
 using sdl::InitSDL;
 
@@ -23,10 +27,17 @@ int main(int argc, char **argv) {
        const int width = 800;
        const int height = 480;
 
+       // temporary
+       SDL_Surface *bg(SDL_CreateRGBSurface(0, width, height, 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF));
+       SDL_FillRect(bg, 0, SDL_MapRGB(bg->format, 0, 0, 0));
+
        try {
                InitSDL sdl;
                InitScreen screen(width, height);
 
+               Application app(screen.Screen(), new BattleState(bg));
+               app.Run();
+
                return 0;
        } catch (exception &e) {
                cerr << "exception in main(): " << e.what() << endl;