-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow.h
92 lines (62 loc) · 2.08 KB
/
window.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef WINDOW_H
#define WINDOW_H
#include "game.h"
#include "SDL2/SDL.h"
#include "SDL2/SDL_ttf.h"
#include "SDL2/SDL_mixer.h"
#include <string>
#include <vector>
enum class Screen{ SELECT, PLAY, REPLAY, DRUM, SEQ, EXIT };
struct Window
{
Window(int windowWidth, int windowHeight);
Window(const Window&) = delete;
Window(Window&&) = delete;
~Window();
Screen SelectScreen();
void UpdateUpdateTimer(unsigned score = 1);
void PollEvents(Game& game);
GridIndex HandleInput(Game& game);
void TryToPlayMusic();
void TryToPlaySoundFX();
void TryToPlayDrumSound(const FoodType& f);
void Draw(const Game& game);
void DrawReplaySelect(const std::vector<ReplayMode>&, int);
bool LoadTextureFromText(const std::string& text, const SDL_Color& color);
void FreeTexture(SDL_Texture*);
struct Font
{
TTF_Font* mFontP{ nullptr };
int mWidth;
int mHeight;
};
SDL_Window* mWindow {nullptr};
SDL_GameController* mController{nullptr};
SDL_Renderer* mRenderer {nullptr};
SDL_Texture* mTexture {nullptr};
Mix_Music* mMusic{ nullptr };
Mix_Chunk* mEatingSound{ nullptr };
Mix_Chunk* mSnareSound{ nullptr };
Mix_Chunk* mKickSound{ nullptr };
Mix_Chunk* mHHSound{ nullptr };
Font mFont {nullptr, 0, 0};
unsigned int mNextUpdate{0};
SDL_Scancode mPrevScanCode{ SDL_Scancode::SDL_SCANCODE_UP };
int mWindowWidth;
int mWindowHeight;
private:
void Reset(Game& g);
void DrawStartMenu(const Game& game);
void DrawGameHelper(const Game& game, const std::string& score);
void DrawPauseHelper(const Game& game);
void DrawStopHelper(const Game& game, const std::string& score);
void RunEventLoop(Game& g);
void StartEventLoop(Game& g);
void StopEventLoop(Game& g);
bool MovedUp(const Uint8* currentKeyStates) const;
bool MovedDown(const Uint8* currentKeyStates) const;
bool MovedLeft(const Uint8* currentKeyStates) const;
bool MovedRight(const Uint8* currentKeyStates) const;
void StringDrawHelper(std::string&, const SDL_Rect&);
};
#endif