From 5ef75aee810e5a687fae24e3f95886241e36efda Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sun, 5 Aug 2012 16:08:30 +0200 Subject: [PATCH] added empty battle state --- Debug/src/battle/subdir.mk | 3 +++ Release/src/battle/subdir.mk | 3 +++ src/battle/BattleState.cpp | 36 +++++++++++++++++++++++++++++++ src/battle/BattleState.h | 42 ++++++++++++++++++++++++++++++++++++ src/main.cpp | 11 ++++++++++ 5 files changed, 95 insertions(+) create mode 100644 src/battle/BattleState.cpp create mode 100644 src/battle/BattleState.h diff --git a/Debug/src/battle/subdir.mk b/Debug/src/battle/subdir.mk index 37e4161..6cc1a8f 100644 --- a/Debug/src/battle/subdir.mk +++ b/Debug/src/battle/subdir.mk @@ -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/Release/src/battle/subdir.mk b/Release/src/battle/subdir.mk index 213b6f0..c2080a7 100644 --- a/Release/src/battle/subdir.mk +++ b/Release/src/battle/subdir.mk @@ -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 index 0000000..25fb09c --- /dev/null +++ b/src/battle/BattleState.cpp @@ -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 index 0000000..b88bae3 --- /dev/null +++ b/src/battle/BattleState.h @@ -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 +#include + +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 monsters; + +}; + +} + +#endif /* BATTLE_BATTLESTATE_H_ */ diff --git a/src/main.cpp b/src/main.cpp index 2040663..780b8c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,12 +5,16 @@ * Author: holy */ +#include "app/Application.h" +#include "battle/BattleState.h" #include "sdl/InitScreen.h" #include "sdl/InitSDL.h" #include #include +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; -- 2.39.2