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
25
namespace
Pelrock {
26
27
static
const
int
kPuzzleScreenWidth = 640;
28
static
const
int
kPuzzleScreenHeight = 400;
29
static
const
int
kNumPuzzleSizes = 4;
30
static
const
int
kTileSizes[kNumPuzzleSizes] = {80, 40, 20, 10};
31
static
const
byte
kEmptyTileColor = 0x0F;
32
33
class
SlidingPuzzle
{
34
public
:
35
SlidingPuzzle
(
PelrockEventManager
*eventMan,
SoundManager
*sound);
36
~SlidingPuzzle
();
37
38
void
run();
39
40
// Persisted across activations so the size cycles each time.
41
static
byte
_sizeIndex;
42
43
private
:
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
Graphics::ManagedSurface
Definition:
managed_surface.h:51
Pelrock::PelrockEventManager
Definition:
events.h:28
Pelrock::SlidingPuzzle
Definition:
slidingpuzzle.h:33
Pelrock::SoundManager
Definition:
sound.h:55
engines
pelrock
slidingpuzzle.h
Generated on Sat Oct 24 2026 09:22:43 for ScummVM API documentation by
1.9.4