ScummVM API documentation
mousetrap.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  *
21  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, MojoTouch has exclusively licensed
23  * this code on November 10th, 2021, to be use in closed-source products.
24  * Therefore, any contributions (commits) to it will also be dual-licensed.
25  *
26  */
27 
28 #ifndef GROOVIE_LOGIC_MOUSETRAP_H
29 #define GROOVIE_LOGIC_MOUSETRAP_H
30 
31 #include "common/random.h"
32 #include "common/system.h"
33 
34 namespace Groovie {
35 
36 /*
37  * Mouse Trap puzzle in the Lab.
38  *
39  * Stauf's Goal is space 1, counting up as you go north east
40  * towards the north corner which is space 5 and the moveable
41  * space to the left of that is space 4.
42  * South east from Stauf's goal is the next line starting with
43  * space 6, counting up as you go north east where the moveable
44  * space to the right of the north corner is space 10
45  *
46  * Next line is 11 (unmovable) to 15 (unmoveable), this line
47  * contains the center space which is space 13
48  * Next line is 16 (moveable) to 20 (moveable)
49  * Next line is 21 (unmovable) to 25 (unmovable), with 25 being
50  * the player's goal door
51  *
52  * Space -2 is the next piece, outside of the box
53  */
55 public:
56  MouseTrapGame(bool easierAi);
57  void run(byte *scriptVariables);
58 
59 private:
60  void init();
61  void sub01(byte *scriptVariables);
62  void sub03(byte *scriptVariables);
63  void sub05(byte *scriptVariables);
64  void sub06(byte *scriptVariables);
65  void sub07(byte *scriptVariables);
66  void sub08(byte *scriptVariables);
67  void sub09(byte *scriptVariables);
68  void copyRoute(int8 x, int8 y);
69  int8 xyToPos(int8 x, int8 y);
70  void posToXY(int8 pos, int8 *x, int8 *y);
71  void copyStateToVars(byte *scriptVariables);
72  int8 findState(int8 val);
73  void flipField(int8 x, int8 y);
74  bool calcSolution();
75  bool havePosInRoute(int8 y, int8 x);
76  void addToRoute(int8 y, int8 x, int8 num);
77  void updateRoute();
78  void popLastStep(int8 *x, int8 *y);
79  void goFarthest(int8 *x, int8 *y);
80  void findMinPointInRoute(int8 *y, int8 *x);
81  int8 calcDistanceToExit();
82  void getBestDirection(int8 *x, int8 *y);
83  void findMaxPointInRoute(int8 *x, int8 *y);
84  int8 findMaxInRoute();
85 
86 
87 private:
88  Common::RandomSource _random;
89  int8 _mouseTrapX, _mouseTrapY;
90  int8 _mouseTrapCounter, _mouseTrapCounter1;
91  int8 _mouseTrapRoute[75];
92  int8 _mouseTrapRouteCopy[76];
93  int8 _mouseTrapCells[31];
94  int8 _mouseTrapPosX, _mouseTrapPosY;
95  int8 _mouseTrapNumSteps;
96  bool _easierAi;
97 };
98 
99 } // End of Groovie namespace
100 
101 #endif // GROOVIE_LOGIC_MOUSETRAP_H
Definition: mousetrap.h:54
Definition: random.h:44
Definition: cursor.h:32