generated from 32blit/32blit-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameState.hpp
79 lines (68 loc) · 2.28 KB
/
GameState.hpp
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
77
78
79
/*
* GameState.hpp - part of 32Blox (revised edition!)
*
* Copyright (C) 2020 Pete Favelle <[email protected]>
*
* This file is released under the MIT License; see LICENSE for details
*
* The GameState is the core of the game, active whenever the game is actually
* in play.
*/
#ifndef _GAMESTATE_HPP_
#define _GAMESTATE_HPP_
#include <forward_list>
#include "AssetFactory.hpp"
#include "Ball.hpp"
#include "HighScore.hpp"
#include "Level.hpp"
#include "OutputManager.hpp"
#include "PowerUp.hpp"
typedef enum
{
BAT_NORMAL,
BAT_NARROW,
BAT_WIDE,
BAT_STICKY,
BAT_MAX
} bat_type_t;
#define FREQ_BOUNDS 96
#define FREQ_BRICK 640
class GameState : public GameStateInterface
{
private:
AssetFactory &assets = AssetFactory::get_instance();
OutputManager &output = OutputManager::get_instance();
HighScore *high_score;
Level *level;
uint8_t lives;
blit::Pen font_pen;
blit::Pen number_pen;
blit::Tween font_tween;
blit::Tween splash_tween;
char splash_message[32];
float bat_position;
float bat_speed;
uint16_t bat_height;
bat_type_t bat_type;
uint16_t score;
uint16_t hiscore;
std::forward_list<Ball*> balls;
std::forward_list<PowerUp*> powerups;
const uint8_t bat_width[BAT_MAX] = { 24, 16, 32, 24 };
void init( void );
void move_bat( float );
blit::Rect brick_to_screen( uint8_t, uint8_t );
blit::Point screen_to_brick( blit::Point );
blit::Rect bat_bounds( void );
void spawn_ball( bool );
void load_level( uint8_t );
public:
GameState( void );
void init( GameStateInterface * );
void fini( GameStateInterface * );
uint16_t get_score( void );
gamestate_t update( uint32_t );
void render( uint32_t );
};
#endif /* _GAMESTATE_HPP_ */
/* End of GameState.hpp */