1 // Brain Party 2 // Copyright (C) 2010 Paul Hudson (http://www.tuxradar.com/brainparty) 3 4 // Brain Party is free software; you can redistribute it and/or 5 // modify it under the terms of the GNU General Public License 6 // as published by the Free Software Foundation; either version 3 7 // of the License, or (at your option) any later version. 8 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 14 // You should have received a copy of the GNU General Public License 15 // along with this program; if not, write to the Free Software 16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 18 #ifndef __PERFECTPATHS_H__ 19 #define __PERFECTPATHS_H__ 20 21 #include "Minigame.h" 22 23 class BPMiniGame_PerfectPaths_Square { 24 public: 25 int X; 26 int Y; 27 int XPos; // XPos and YPos are pixel co-ordinates to save calculations when drawing 28 int YPos; 29 Colour* Col; 30 int Difficulty; 31 const char* DifficultyStr; 32 33 int MoveCalc; // used for flood fill best move calculation; set high so that any path is better 34 int Pos; // the position of the square in the Squares list; saves looking it up when doing flood fills 35 BPMiniGame_PerfectPaths_Square()36 BPMiniGame_PerfectPaths_Square() { 37 X = Y = XPos = YPos = Difficulty = Pos = 0; 38 MoveCalc = 9999; 39 DifficultyStr = NULL; 40 } 41 ~BPMiniGame_PerfectPaths_Square()42 ~BPMiniGame_PerfectPaths_Square() { 43 44 } 45 }; 46 47 48 49 class BPMiniGame_PerfectPaths : public BPMiniGame { 50 public: 51 BPMiniGame_PerfectPaths(BPGame* game); 52 ~BPMiniGame_PerfectPaths(); 53 void Start(); 54 int GetWeight(); 55 void Render(); 56 void Tick(); 57 void OnMouseUp(); 58 void OnMouseMove(); 59 void OnMouseDown(); 60 void CalculateOurScore(); 61 void CheckResult(); 62 void LevelUp(); 63 void CalculateBestMove(); 64 void FloodFill(BPMiniGame_PerfectPaths_Square* square); 65 bool CanMove(BPMiniGame_PerfectPaths_Square* square1, BPMiniGame_PerfectPaths_Square* square2); 66 void SetScore(); 67 void RenderPerfect(); 68 void RenderOK(); 69 protected: 70 Texture* sfcBackground; 71 72 Texture* sfcPerfect; 73 Texture* sfcOK; 74 75 BPList<int> StartPositions; 76 BPList<int> EndPositions; 77 BPPList<Texture*> LoNumbers; 78 BPPList<Texture*> HiNumbers; 79 80 BPMiniGame_PerfectPaths_Square* StartPos; 81 BPMiniGame_PerfectPaths_Square* EndPos; 82 83 BPPList<BPMiniGame_PerfectPaths_Square*> Squares; 84 BPList<BPMiniGame_PerfectPaths_Square*> Moves; 85 BPList<BPMiniGame_PerfectPaths_Square*> MoveSquares; // used for flood fill best move calculation 86 87 int CurrentScore; 88 int BestScore; 89 90 SpriteFont* sfcScore; 91 92 int LastDiff; 93 int TotalDiff; 94 95 int TimeStarted; 96 int CurrentLevel; 97 98 MiniGameStates GameState; 99 int LastStateChange; 100 }; 101 102 #endif 103