ScummVM API documentation
slidingpuzzle.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
22#ifndef PELROCK_SLIDINGPUZZLE_H
23#define PELROCK_SLIDINGPUZZLE_H
24
25namespace Pelrock {
26
27static const int kPuzzleScreenWidth = 640;
28static const int kPuzzleScreenHeight = 400;
29static const int kNumPuzzleSizes = 4;
30static const int kTileSizes[kNumPuzzleSizes] = {80, 40, 20, 10};
31static const byte kEmptyTileColor = 0x0F;
32
34public:
37
38 void run();
39
40 // Persisted across activations so the size cycles each time.
41 static byte _sizeIndex;
42
43private:
44 PelrockEventManager *_events;
45 SoundManager *_sound;
46
47 void playTileSound();
48
49 int _tileSize;
50 int _gridWidth;
51 int _gridHeight;
52 int _totalTiles; // gridWidth * gridHeight`
53 int _emptyPos; // index of the empty (removed) tile
54 uint16 *_tileMap; // logical position -> original tile index
55
56 Graphics::ManagedSurface _puzzleBuffer;
57
58 void initGrid();
59 void drawGridLines();
60 void swapTiles(int a, int b);
61 void fillEmptyTile(int pos);
62 void shuffleLoop();
63 void ensureSolvable();
64 void puzzleLoop();
65 bool handleClick(int screenX, int screenY);
66 bool isSolved() const;
67 void showOriginalImage();
68 void present();
69};
70
71} // End of namespace Pelrock
72
73#endif // PELROCK_SLIDING_PUZZLE_H
Definition: managed_surface.h:51
Definition: events.h:28
Definition: slidingpuzzle.h:33
Definition: sound.h:55