-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStateScreen.h
76 lines (66 loc) · 1.65 KB
/
StateScreen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*****************************************************************//**
* \file StateScreen.h
* \brief Abstract class for screen at each state
*
* \author Chau Le
* \date July 2021
*********************************************************************/
#pragma once
#ifndef STATE_SCREEN_H
#define STATE_SCREEN_H
#include <SFML/Graphics.hpp>
#include "AssetManager.h"
class StateManager;
class StateScreen
{
private:
protected:
sf::Texture backgroundTexture;
sf::Sprite* background = nullptr;
StateManager &stateManager;
AssetManager* assetManager = AssetManager::getInstance();
virtual void loadStaticAssets() {};
public:
StateScreen(StateManager& stateManager);
~StateScreen();
/**
* Life cycle function. Run each frame.
*
* \param window Rendering window
*/
virtual void tick(const float & dt, sf::RenderWindow& window) = 0;
/**
* Function for drawing the screen.
*
* \param window Rendering window
*/
virtual void render(sf::RenderWindow& window) {
window.clear();
if (background)
{
window.draw(*background);
}
};
/**
* Function run when a keyboard key event is detected.
*
* \param state Which the app is in
*
* \param key Was pressed
*/
virtual void keyEvent(const float & dt, sf::Event event) = 0;
/**
* Function run when a mouse event is detected.
*
*/
virtual void mouseEvent(const float & dt, sf::RenderWindow& window, sf::Event event) = 0;
/**
* Function run when a mouse scroll event is detected.
*
*/
virtual void mouseScrollEvent(const float & dt, sf::RenderWindow& window, sf::Event event) {};
virtual void init() {};
virtual void pause() {};
virtual void resume() {};
};
#endif