From bf34d835e4ea49bd4ef2e5de2b1fea2fd3c95adc Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Tue, 29 Nov 2022 18:19:25 +0100 Subject: Start to use a normal game structure: - App class that has a StateStack - StateStack - Some State definiton and a minimal TitleState to use as a template - Makefile updated accordingly - Delete old code that was there for testing --- src/states/ids.h | 19 +++++++++++++++++++ src/states/titleState.cpp | 25 +++++++++++++++++++++++++ src/states/titleState.h | 14 ++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 src/states/ids.h create mode 100644 src/states/titleState.cpp create mode 100644 src/states/titleState.h (limited to 'src/states') diff --git a/src/states/ids.h b/src/states/ids.h new file mode 100644 index 0000000..d8c69da --- /dev/null +++ b/src/states/ids.h @@ -0,0 +1,19 @@ +#ifndef STATE_IDS_H +#define STATE_IDS_H + +namespace States +{ + enum Id + { + None, + Title, + Menu, + Game, + Loading, + Pause, + Settings, + Tutorial + }; +} + +#endif // STATE_IDS_H diff --git a/src/states/titleState.cpp b/src/states/titleState.cpp new file mode 100644 index 0000000..a0d17c8 --- /dev/null +++ b/src/states/titleState.cpp @@ -0,0 +1,25 @@ +#include "titleState.h" +#include + +TitleState::TitleState(StateStack &stack, State::Context context) + : State(stack, context) +{ + +} + +void TitleState::update(sf::Time dt){ + +} + +void TitleState::render(){ + sf::RectangleShape rectangle; + rectangle.setSize(sf::Vector2f(100, 50)); + rectangle.setOutlineColor(sf::Color::Red); + rectangle.setOutlineThickness(5); + rectangle.setPosition(10, 20); + context_.window->draw(rectangle); +} + +void TitleState::handleEvent(const sf::Event &event){ + +} diff --git a/src/states/titleState.h b/src/states/titleState.h new file mode 100644 index 0000000..8b914d8 --- /dev/null +++ b/src/states/titleState.h @@ -0,0 +1,14 @@ +#ifndef STATES_TITLESTATE_H +#define STATES_TITLESTATE_H + +#include "../states.h" + +class TitleState : public State{ + public: + TitleState(StateStack &stack, State::Context context); + virtual void update(sf::Time dt) override; + virtual void render() override; + virtual void handleEvent(const sf::Event &event) override; +}; + +#endif // STATES_TITLESTATE_H -- cgit v1.2.3