Commit 7140a4ed authored by Ian Wadham's avatar Ian Wadham

Partly implemented digging.

svn path=/branches/work/kgoldrunner/; revision=921032
parent 098e4d1a
......@@ -161,7 +161,7 @@ KGoldrunner::KGoldrunner()
// IDW toolBar ("editToolbar")->setAllowedAreas (Qt::TopToolBarArea);
// Set mouse control of the hero as the default.
game->setMouseMode (true);
game->setControlMode (MOUSE);
// Do NOT paint main widget yet (title, menu, status bar, blank playfield).
// Instead, queue a call to the "KGoldrunner_2" constructor extension.
......@@ -349,6 +349,7 @@ void KGoldrunner::setupActions()
// Mouse Controls Hero
// Keyboard Controls Hero
// Laptop Hybrid
// --------------------------
setMouse = new KToggleAction (i18n ("&Mouse Controls Hero"), this);
......@@ -364,9 +365,16 @@ void KGoldrunner::setupActions()
actionCollection()->addAction ("keyboard_mode", setKeyboard);
connect (setKeyboard,SIGNAL (triggered (bool)), this, SLOT (setKeyBoardMode()));
setLaptop = new KToggleAction (i18n ("&Hybrid Control (Laptop)"), this);
setLaptop->setToolTip (i18n ("Pointer controls hero: dig using keyboard"));
setLaptop->setWhatsThis (i18n ("Use the the laptop's pointer device to control the hero's moves and the keyboard for digging left and right"));
actionCollection()->addAction ("laptop_mode", setLaptop);
connect (setLaptop, SIGNAL (triggered (bool)), this, SLOT(setLaptopMode()));
QActionGroup* controlGrp = new QActionGroup (this);
controlGrp->addAction (setMouse);
controlGrp->addAction (setKeyboard);
controlGrp->addAction (setLaptop);
controlGrp->setExclusive (true);
setMouse->setChecked (true);
......@@ -788,8 +796,9 @@ void KGoldrunner::editGameInfo() {}// Force compile IDW game->editCollection (SL
// Local slots to set mouse or keyboard control of the hero.
void KGoldrunner::setMouseMode() {game->setMouseMode (true);}
void KGoldrunner::setKeyBoardMode() {game->setMouseMode (false);}
void KGoldrunner::setMouseMode() {game->setControlMode (MOUSE);}
void KGoldrunner::setKeyBoardMode() {game->setControlMode (KEYBOARD);}
void KGoldrunner::setLaptopMode() {game->setControlMode (LAPTOP);}
// Local slots to set game speed.
......
......@@ -107,9 +107,10 @@ private slots:
void createGame();
void editGameInfo();
// Local slots to set mouse/keyboard control of the hero.
// Local slots to set mouse/keyboard or laptop-hybrid control of the hero.
void setMouseMode();
void setKeyBoardMode();
void setLaptopMode();
// Local slots to set game speed.
void normalSpeed();
......@@ -185,6 +186,7 @@ private:
KToggleFullScreenAction *fullScreen; // Show Full Screen Mode on menu.
KToggleAction * setMouse; // Show mouse/keyboard mode on menu.
KToggleAction * setKeyboard; // Show mouse/keyboard mode on menu.
KToggleAction * setLaptop; // Show mouse/keyboard mode on menu.
KToggleAction * tradRules; // Set Traditional rules.
KToggleAction * kgrRules; // Set KGoldrunner rules.
......
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<gui version="7" name="kgoldrunner" >
<gui version="8" name="kgoldrunner" >
<MenuBar>
<Menu name="game" >
<Action append="save_merge" name="save_edits" />
......@@ -25,6 +25,7 @@
<Separator append="save_merge" />
<Action append="save_merge" name="mouse_mode" />
<Action append="save_merge" name="keyboard_mode" />
<Action append="save_merge" name="laptop_mode" />
<Separator append="save_merge" />
<Action append="save_merge" name="normal_speed" />
<Action append="save_merge" name="beginner_speed" />
......
......@@ -474,6 +474,7 @@ void KGrCanvas::updateLives (int lives)
void KGrCanvas::mousePressEvent (QMouseEvent * mouseEvent)
{
kDebug() << "Button" << mouseEvent->button();
emit mouseClick (mouseEvent->button());
}
......
......@@ -87,10 +87,6 @@ enum Position {RIGHTWALK1, RIGHTWALK2, RIGHTWALK3, RIGHTWALK4,
FALL1, FALL2};
enum Status {STANDING, FALLING, WALKING, CLIMBING, CAPTIVE};
// TODO - Should be in kgrglobals.h .....
enum Direction {STAND, RIGHT, LEFT, UP, DOWN, nDirections};
// enum Direction {RIGHT = 0x1, LEFT = 0x2, UP = 0x4, DOWN = 0x8,
// STAND = 0x10}; // OBSOLESCENT - 13/1/09
enum SearchStrategy {LOW, MEDIUM, HIGH};
// Keyboard action codes
......
......@@ -434,8 +434,11 @@ void KGrGame::finalBreath()
// Fix bug 95202: Avoid re-starting if the player selected
// edit mode before the 1.5 seconds were up.
if (! editMode) {
// OBSOLESCENT - 18/1/09 enemyCount = 0; // Hero is dead: re-start the level.
// OBSOLESCENT - 18/1/09 enemyCount = 0; // Hero is dead: re-start the level.
loadLevel (level);
if (levelPlayer) {
levelPlayer->prepareToPlay();
}
}
gameFrozen = false; // Unfreeze the game, but don't move yet.
}
......@@ -504,14 +507,17 @@ void KGrGame::loseNugget()
// return (hero); // Return a pointer to the hero.
// }
void KGrGame::setMouseMode (bool on_off)
void KGrGame::setControlMode (const Control mode)
{
mouseMode = on_off; // Set mouse mode on or off.
controlMode = mode;
if (levelPlayer) {
levelPlayer->setControlMode (mode);
}
}
bool KGrGame::inMouseMode()
{
return (mouseMode); // Return true if game is under mouse control.
return (controlMode == MOUSE);
}
bool KGrGame::inEditMode()
......@@ -718,7 +724,7 @@ int KGrGame::loadLevel (int levelNo)
levelPlayer = new KGrLevelPlayer (this, testGame, &levelData); // TESTING
levelPlayer->init (view);
levelPlayer->init (view, controlMode);
// If there is a name, translate the UTF-8 coded QByteArray right now.
levelName = (levelData.name.size() > 0) ?
......@@ -731,9 +737,10 @@ int KGrGame::loadLevel (int levelNo)
// If there is a hint, translate it right now.
levelHint = (len > 0) ? i18n ((const char *) levelData.hint) : "";
// TODO - Handle editor connections inside the editor.
// Disconnect edit-mode slots from signals from "view".
disconnect (view, SIGNAL (mouseClick (int)), 0, 0);
disconnect (view, SIGNAL (mouseLetGo (int)), 0, 0);
// disconnect (view, SIGNAL (mouseClick (int)), 0, 0);
// disconnect (view, SIGNAL (mouseLetGo (int)), 0, 0);
// if (newLevel) {
// OBSOLESCENT - 9/1/09 hero->setEnemyList (&enemies);
......@@ -758,12 +765,6 @@ int KGrGame::loadLevel (int levelNo)
// Re-draw the playfield frame, level title and figures.
view->setTitle (getTitle());
// If in mouse mode, not keyboard mode, put the mouse pointer on the hero.
if (mouseMode) {
// TODO - How do we know where the hero is? Do this in levelPlayer?
// view->setMousePos (startI, startJ); // OBSOLESCENT - 30/1/09
}
// If we are starting a new level, save it in the player's config file.
if (newLevel) {
KConfigGroup gameGroup (KGlobal::config(), "KDEGame");
......@@ -772,9 +773,6 @@ int KGrGame::loadLevel (int levelNo)
gameGroup.sync(); // Ensure that the entry goes to disk.
}
// Connect play-mode slot to signal from "view".
connect (view, SIGNAL (mouseClick (int)), SLOT (doDig (int)));
// Re-enable player input.
loading = false;
......@@ -801,11 +799,6 @@ void KGrGame::showTutorialMessages (int levelNo)
if (levelPlayer) {
levelPlayer->prepareToPlay();
}
// If in mouse mode, make sure the mouse pointer is back on the hero.
if (mouseMode) {
// TODO - How do we know where the hero is? Do this in levelPlayer?
// view->setMousePos (startI, startJ); // OBSOLESCENT - 30/1/09
}
setMessageFreeze (false); // Let the level begin.
}
......@@ -990,7 +983,7 @@ void KGrGame::readMousePos()
if (loading) return;
// If game control is currently by keyboard, ignore the mouse.
if ((! mouseMode) && (! editMode) && (! gameFrozen)) {
if ((controlMode == KEYBOARD) && (! editMode) && (! gameFrozen)) {
levelPlayer->tick ();
return;
}
......@@ -1028,41 +1021,22 @@ void KGrGame::readMousePos()
}
}
void KGrGame::doDig (int button) {
// If game control is currently by keyboard, ignore the mouse.
if (editMode) return;
if (! mouseMode) return;
// If loading a level for play or editing, ignore mouse-button input.
if ((! loading) && (! gameFrozen)) {
// OBSOLESCENT - 7/1/09 }
// if (! hero->started) {
// startPlaying(); // If first player-input, start playing.
// }
switch (button) {
// OBSOLESCENT - 7/1/09
case Qt::LeftButton: break; // hero->digLeft(); break;
case Qt::RightButton: break; // hero->digRight(); break;
default: break;
}
}
}
void KGrGame::kbControl (int dirn)
{
kDebug() << "Keystroke setting direction" << dirn;
if (editMode) return;
// Using keyboard control can automatically disable mouse control.
if (mouseMode) {
if ((controlMode == MOUSE) ||
((controlMode == LAPTOP) && (dirn != DIG_RIGHT) && (dirn != DIG_LEFT)))
{
// Halt the game while a message is displayed.
setMessageFreeze (true);
switch (KMessageBox::questionYesNo (view,
i18n ("You have pressed a key that can be used to move the "
i18n ("You have pressed a key that can be used to control the "
"Hero. Do you want to switch automatically to keyboard "
"control? Mouse control is easier to use in the long term "
"control? Pointer control is easier to use in the long term "
"- like riding a bike rather than walking!"),
i18n ("Switch to Keyboard Mode"),
KGuiItem (i18n ("Switch to &Keyboard Mode")),
......@@ -1070,10 +1044,9 @@ void KGrGame::kbControl (int dirn)
i18n ("Keyboard Mode")))
{
case KMessageBox::Yes:
mouseMode = false; // Set mouse mode OFF.
controlMode = KEYBOARD;
// TODO - Connect these signals in kgoldrunner.cpp somewhere.
emit setToggle ("mouse_mode", false); // Adjust Settings menu.
emit setToggle ("keyboard_mode", true);
emit setToggle ("keyboard_mode", true); // Adjust Settings menu.
break;
case KMessageBox::No:
break;
......@@ -1082,19 +1055,15 @@ void KGrGame::kbControl (int dirn)
// Unfreeze the game, but only if it was previously unfrozen.
setMessageFreeze (false);
if (mouseMode)
return; // Stay in Mouse Mode.
if (controlMode != KEYBOARD) {
return; // Stay in Mouse or Laptop Mode.
}
}
// if (level != 0)
// {
// OBSOLESCENT - 9/1/09 if (! hero->started) // Start when first movement
// startPlaying(); // key is pressed ...
// TODO - Pass direction to the hero heroAction (movement);
// }
// Accept keystroke to set next direction, even when the game is frozen.
// TODO - But what if it is a DIG key?
if (levelPlayer) {
levelPlayer->setDirection ((Direction) dirn);
levelPlayer->setDirectionByKey ((Direction) dirn);
}
}
......
......@@ -92,7 +92,9 @@ public slots:
void setPlaySounds (bool on_off); // Set sound enabled or disabled.
void setMouseMode (bool on_off); // Set mouse OR keyboard control.
// Set mouse, keyboard or laptop-hybrid control of the hero.
void setControlMode (const Control mode);
void startLevel (int startingAt, int requestedLevel);
void newGame (const int lev, const int gameIndex);
void startTutorial(); // Start tutorial game.
......@@ -145,9 +147,8 @@ private slots:
void quickStartQuit();
private slots:
void finalBreath(); // Hero is dead: re-start the level.
void finalBreath(); // Hero is dead: re-start the level.
void readMousePos(); // Timed reading of mouse position.
void doDig (int button); // Dig when under mouse-button control.
private:
void setBlankLevel (bool playable);
......@@ -244,7 +245,8 @@ public slots: // Slots connected to the Menu and Edit Toolbar.
private:
KGrEditor * editor; // The level-editor object.
bool mouseMode; // Flag to set up keyboard OR mouse control.
Control controlMode; // How to control the hero (e.g. K/B or mouse).
bool editMode; // Flag to change keyboard and mouse functions.
char editObj; // Type of object to be painted by the mouse.
bool paintEditObj; // Sets painting on/off (toggled by clicking).
......
......@@ -6,6 +6,9 @@ const char TraditionalRules = 'T';
const char KGoldrunnerRules = 'K';
const char ScavengerRules = 'S';
/// Modes for controlling the hero in KGoldrunner.
enum Control {MOUSE, KEYBOARD, LAPTOP};
/// KGrGameData structure: contains attributes of a KGoldrunner game.
class KGrGameData
{
......@@ -44,8 +47,8 @@ typedef char Flags;
enum Axis {X, Y, nAxes};
typedef int Vector2D [nAxes];
// enum Direction {STAND, RIGHT, LEFT, UP, DOWN, nDirections};
enum Digging {DIG_RIGHT = nDirections, DIG_LEFT};
enum Direction {STAND, RIGHT, LEFT, UP, DOWN, nDirections,
DIG_RIGHT = nDirections, DIG_LEFT};
const DirectionFlag dFlag [nDirections] = {
0x10, // Can stand.
......
......@@ -20,7 +20,7 @@
KGrLevelGrid::KGrLevelGrid (QObject * parent, KGrLevelData * theLevelData)
:
QObject (parent)
QObject (parent)
{
// Put a concrete wall all round the layout: left, right, top and bottom.
// This saves ever having to test for being at the edge of the layout.
......@@ -68,8 +68,6 @@ KGrLevelGrid::KGrLevelGrid (QObject * parent, KGrLevelData * theLevelData)
inRow = inRow + inWidth;
outRow = outRow + width;
}
calculateAccess();
}
KGrLevelGrid::~KGrLevelGrid()
......@@ -77,103 +75,153 @@ KGrLevelGrid::~KGrLevelGrid()
}
// Inline functions (see kgrlevelgrid.h).
// char cellType (int i, int j)
// char heroMoves (int i, int j)
// char enemyMoves (int i, int j)
// char cellState (int i, int j)
// char cellType
// char heroMoves
// char enemyMoves
// char cellState
// void gotGold
void KGrLevelGrid::calculateAccess()
void KGrLevelGrid::calculateAccess (bool pRunThruHole)
{
runThruHole = pRunThruHole; // Save a copy of the runThruHole rule.
char here;
bool canEnter;
// Calculate which cells can be entered (N.B. USEDHOLE is a trapped enemy).
for (int j = 1; j < height - 1; j++) {
for (int i = 1; i < width - 1; i++) {
here = cellType (i, j);
if ((here != BRICK) && (here != CONCRETE) && (here != FBRICK)) {
heroAccess [index (i, j)] = ENTERABLE;
enemyAccess [index (i, j)] = ENTERABLE;
}
here = cellType (i, j);
canEnter = (here != BRICK) && (here != CONCRETE) &&
(here != FBRICK) && (here != USEDHOLE);
heroAccess [index (i, j)] = canEnter ? ENTERABLE : 0;
enemyAccess [index (i, j)] = canEnter ? ENTERABLE : 0;
}
}
Flags below;
Flags access = 0;
// Calculate the access *from* each cell to its neighbours.
for (int j = 1; j < height - 1; j++) {
for (int i = 1; i < width - 1; i++) {
here = cellType (i, j);
below = cellType (i, j + 1);
calculateCellAccess (i, j);
}
}
}
access = heroMoves (i, j);
void KGrLevelGrid::changeCellAt (const int i, const int j, const char type)
{
int position = index (i, j);
bool canEnter = (type != BRICK) && (type != CONCRETE) &&
(type != FBRICK) && (type != USEDHOLE);
layout [position] = type;
heroAccess [position] = canEnter ? ENTERABLE : 0;
enemyAccess [position] = canEnter ? ENTERABLE : 0;
calculateCellAccess (i, j); // Recalculate access *from* this cell
// and access *to* it
calculateCellAccess (i, j - 1); // from above,
calculateCellAccess (i - 1, j); // from left,
calculateCellAccess (i + 1, j); // from right,
calculateCellAccess (i, j + 1); // and from below.
}
// Cannot enter brick or concrete: can enter false brick from above.
if (! (access & ENTERABLE) && (here != FBRICK)) {
access = 0;
}
// If can stand or hang on anything, allow down, left and right.
else if ((below == BRICK) || (below == CONCRETE) ||
(below == LADDER) || (here == LADDER) || (here == POLE)) {
access |= (dFlag [STAND] | dFlag [DOWN] |
dFlag [LEFT] | dFlag [RIGHT]);
}
// If cannot stand or hang, can only go down (space or false brick).
else {
access |= dFlag [DOWN];
}
// Can only go up if there is a ladder here.
if (here == LADDER) {
access |= dFlag [UP];
}
void KGrLevelGrid::calculateCellAccess (const int i, const int j)
{
Flags access = 0;
char here = cellType (i, j);
char below = cellType (i, j + 1);
int enter = (access & ENTERABLE) ? 1 : 0;
int stand = (access & dFlag [STAND]) ? 1 : 0;
int u = (access & dFlag [UP]) ? 1 : 0;
int d = (access & dFlag [DOWN]) ? 1 : 0;
int l = (access & dFlag [LEFT]) ? 1 : 0;
int r = (access & dFlag [RIGHT]) ? 1 : 0;
if ((i == 14) && (j == 20))
fprintf (stderr, "[%02d,%02d] %c %02x E %d S %d U %d D %d L %d R %d ***\n",
i, j, here, access, enter, stand, u, d, l, r);
// Mask out directions that are blocked above, below, L or R.
if (! (heroMoves (i, j - 1) & ENTERABLE)) {
access = ~dFlag [UP] & access; // Cannot go up.
}
if (! (heroMoves (i - 1, j) & ENTERABLE)) {
access = ~dFlag [LEFT] & access; // Cannot go left.
}
if (! (heroMoves (i + 1, j) & ENTERABLE)) {
access = ~dFlag [RIGHT] & access; // Cannot go right.
}
if (! (heroMoves (i, j + 1) & ENTERABLE)) {
if (below != FBRICK) {
access = ~dFlag [DOWN] & access; // Cannot go down.
}
}
access = heroMoves (i, j) & ENTERABLE;
fprintf (stderr, "[%02d,%02d] %c access %02x below %c\n",
i, j, here, access, below);
enter = (access & ENTERABLE) ? 1 : 0;
stand = (access & dFlag [STAND]) ? 1 : 0;
u = (access & dFlag [UP]) ? 1 : 0;
d = (access & dFlag [DOWN]) ? 1 : 0;
l = (access & dFlag [LEFT]) ? 1 : 0;
r = (access & dFlag [RIGHT]) ? 1 : 0;
if ((i == 14) && (j == 20))
fprintf (stderr, "[%02d,%02d] %c %02x E %d S %d U %d D %d L %d R %d ***\n",
i, j, here, access, enter, stand, u, d, l, r);
heroAccess [index (i, j)] |= access;
access = heroAccess [index (i, j)];
enter = (access & ENTERABLE) ? 1 : 0;
stand = (access & dFlag [STAND]) ? 1 : 0;
u = (access & dFlag [UP]) ? 1 : 0;
d = (access & dFlag [DOWN]) ? 1 : 0;
l = (access & dFlag [LEFT]) ? 1 : 0;
r = (access & dFlag [RIGHT]) ? 1 : 0;
fprintf (stderr, "[%02d,%02d] %c %02x E %d S %d U %d D %d L %d R %d\n",
i, j, here, access, enter, stand, u, d, l, r);
// Enemy access is the same as the hero's when no bricks are open.
enemyAccess [index (i, j)] = heroAccess [index (i, j)];
}
// Cannot enter brick or concrete: can enter false brick from above.
if (! (access & ENTERABLE) && (here != FBRICK)) {
access = 0;
}
// If can stand or hang on anything, allow down, left and right.
else if ((below == BRICK) || (below == CONCRETE) || (below == USEDHOLE) ||
(below == LADDER) || (here == LADDER) || (here == POLE)) {
fprintf (stderr, "Can stand\n");
access |= (dFlag [STAND] | dFlag [DOWN] |
dFlag [LEFT] | dFlag [RIGHT]);
}
// If cannot stand or hang, can only go down (space or false brick).
else {
fprintf (stderr, "Cannot stand\n");
access |= dFlag [DOWN];
}
// Can only go up if there is a ladder here.
if (here == LADDER) {
access |= dFlag [UP];
}
int enter = (access & ENTERABLE) ? 1 : 0;
int stand = (access & dFlag [STAND]) ? 1 : 0;
int u = (access & dFlag [UP]) ? 1 : 0;
int d = (access & dFlag [DOWN]) ? 1 : 0;
int l = (access & dFlag [LEFT]) ? 1 : 0;
int r = (access & dFlag [RIGHT]) ? 1 : 0;
if (below == HOLE)
fprintf (stderr, "[%02d,%02d] %c %02x E %d S %d U %d D %d L %d R %d ***\n",
i, j, here, access, enter, stand, u, d, l, r);
// Mask out directions that are blocked above, below, L or R.
if (! (heroMoves (i, j - 1) & ENTERABLE)) {
access = ~dFlag [UP] & access; // Cannot go up.
}
if (! (heroMoves (i - 1, j) & ENTERABLE)) {
access = ~dFlag [LEFT] & access; // Cannot go left.
}
if (! (heroMoves (i + 1, j) & ENTERABLE)) {
access = ~dFlag [RIGHT] & access; // Cannot go right.
}
if (! (heroMoves (i, j + 1) & ENTERABLE)) {
if (below != FBRICK) {
access = ~dFlag [DOWN] & access; // Cannot go down.
}
}
enter = (access & ENTERABLE) ? 1 : 0;
stand = (access & dFlag [STAND]) ? 1 : 0;
u = (access & dFlag [UP]) ? 1 : 0;
d = (access & dFlag [DOWN]) ? 1 : 0;
l = (access & dFlag [LEFT]) ? 1 : 0;
r = (access & dFlag [RIGHT]) ? 1 : 0;
if (below == HOLE)
fprintf (stderr, "[%02d,%02d] %c %02x E %d S %d U %d D %d L %d R %d ***\n",
i, j, here, access, enter, stand, u, d, l, r);
heroAccess [index (i, j)] = access;
enter = (access & ENTERABLE) ? 1 : 0;
stand = (access & dFlag [STAND]) ? 1 : 0;
u = (access & dFlag [UP]) ? 1 : 0;
d = (access & dFlag [DOWN]) ? 1 : 0;
l = (access & dFlag [LEFT]) ? 1 : 0;
r = (access & dFlag [RIGHT]) ? 1 : 0;
fprintf (stderr, "[%02d,%02d] %c %02x E %d S %d U %d D %d L %d R %d\n",
i, j, here, access, enter, stand, u, d, l, r);
// Enemy access is the same as the hero's when no holes are open.
enemyAccess [index (i, j)] = heroAccess [index (i, j)];
if (here == USEDHOLE) {
enemyAccess [index (i, j)] = UP; // Can only climb out of hole.
}
if (! runThruHole) { // Check the rule.
char mask;
mask = (cellType (i - 1, j) == HOLE) ? dFlag [LEFT] : 0;
mask = (cellType (i + 1, j) == HOLE) ? (dFlag [RIGHT] | mask) : mask;
enemyAccess [index (i, j)] &= ~mask; // Block access to holes at L/R.
}
heroAccess [index (i, j)] |= access;
access = heroAccess [index (i, j)];
enter = (access & ENTERABLE) ? 1 : 0;
stand = (access & dFlag [STAND]) ? 1 : 0;
u = (access & dFlag [UP]) ? 1 : 0;
d = (access & dFlag [DOWN]) ? 1 : 0;
l = (access & dFlag [LEFT]) ? 1 : 0;
r = (access & dFlag [RIGHT]) ? 1 : 0;
fprintf (stderr, "[%02d,%02d] %c %02x E %d S %d U %d D %d L %d R %d Enem\n",
i, j, here, access, enter, stand, u, d, l, r);
}
#include "kgrlevelgrid.moc"
......@@ -32,7 +32,7 @@ public:
KGrLevelGrid (QObject * parent, KGrLevelData * theLevelData);
~KGrLevelGrid();
inline char cellType (int i, int j) {
inline char cellType (int i, int j) {
return layout [i + j * width];
}
......@@ -44,25 +44,29 @@ public:
return enemyAccess [i + j * width];
}
inline char cellState (int i, int j) {
inline char cellState (int i, int j) {
return cellStates [i + j * width];
}
public slots:
inline void gotGold (const int, // Don't care which spriteID did it.
const int i, const int j, const bool runnerHasGold)
{
inline void gotGold (const int i, const int j, const bool runnerHasGold) {
layout [i + j * width] = (runnerHasGold) ? FREE : NUGGET;
}
void calculateAccess (bool pRunThruHole);
void changeCellAt (const int i, const int j, const char type);
private:
inline int index (int i, int j) {
return (i + j * width);
}
void calculateAccess();
int width;
int height;
void calculateCellAccess (const int i, const int j);
int width;