forked from harmattan/brainparty
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMinigame.h
131 lines (101 loc) · 3.51 KB
/
Minigame.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// Brain Party
// Copyright (C) 2010 Paul Hudson (http://www.tuxradar.com/brainparty)
// Brain Party is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __MINIGAME_H__
#define __MINIGAME_H__
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include "BPGame.h"
#include "BPPoint.h"
#include "SpriteFont.h"
#include "BPList.h"
enum RankTypes { NONE, FAIL, BRONZE, SILVER, GOLD, PLATINUM }; // "NONE" is required, otherwise the default is "FAIL"
enum MiniGameStates { SHOWING, GUESSING, PAUSING, THINKING, WAITING, CHANGING, MOVES, MOVING, REMEMBER, CORRECT, WRONG, SUCCESS, FAILURE, FADE_IN, FADE_OUT };
enum MiniGameTypes { PUZZLE, LIVELY, ACTION };
enum ReturnTypes { RT_NORMAL, RT_SECRET, RT_BRAINBOOST };
class BPGame;
class SpriteFont;
class BPMiniGame_BGStar {
public:
int Type;
float Speed;
BPPoint Pos;
};
class BPMiniGame {
public:
ReturnTypes ReturnType; // controls which game screens return to y
int FinishedTime; // set to Environment.TickCount when game should no longer have Tick() called
const char* GameTitle;
const char* GameHelp;
const char* GameHelp2;
SpriteFont* sfcGameTitle;
SpriteFont* sfcGameHelp;
MiniGameTypes MiniGameType;
int FinalWeight;
RankTypes FinalRank;
const char* FinalGrade;
SpriteFont* sfcFinalWeight;
SpriteFont* sfcFinalGrade;
BPPoint TouchEvent;
BPGame* TheGame;
BPMiniGame(BPGame* game);
virtual ~BPMiniGame();
void Init(); // called after the constructor so that any descendent constructors have finished
virtual void Start() = 0;
virtual int GetWeight() = 0;
virtual void SetMarathon();
static RankTypes GetRank(int Weight);
const char* GetGrade(int Weight);
void TickMiniGame();
void RenderMiniGame();
void RenderScore();
virtual void OnMouseDown() = 0;
virtual void OnMouseUp() = 0;
virtual void OnMouseMove() = 0;
void HandleMouseUp(BPPoint e);
void HandleMouseDown(BPPoint e);
void HandleMouseMove(BPPoint e);
void DrawProfessorText();
void PlayMusic();
protected:
static const int MiniGameWidth = 320;
static const int MiniGameHalfWidth = 160;
static const int MiniGameHeight = 480; // note: needs to be screen height minus the height of the info bar
static const int MiniGameHalfHeight = 240;
bool RedrawClock();
virtual void Render() = 0;
virtual void Tick() = 0;
void Success();
void Failure();
void CalculateResult();
void ContinueGame();
void GoBack();
void ShowHelp();
int DivRem(int Num, int Div, int &Rem);
int Round(double num);
int MinMax(int num);
void RenderCorrect();
void RenderWrong();
void GenerateStarfield(BPPList<BPMiniGame_BGStar*> &list);
void UpdateStarfield(BPPList<BPMiniGame_BGStar*> &list);
void DrawStarfield(BPPList<BPMiniGame_BGStar*> &list);
bool MarathonMode; // used by some games to hide/stop the timer so players can play as long as they want to
private:
bool InTick;
bool BackDown;
bool HelpDown;
int WantToQuit;
};
#endif