• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

kgoldrunner

  • sources
  • kde-4.14
  • kdegames
  • kgoldrunner
  • src
kgrlevelgrid.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright 2009 Ian Wadham <iandw.au@gmail.com> *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * 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, see <http://www.gnu.org/licenses/>. *
16  ****************************************************************************/
17 
18 #ifndef KGRLEVELGRID_H
19 #define KGRLEVELGRID_H
20 
21 #include "kgrglobals.h"
22 
23 #include <QObject>
24 #include <QVector>
25 #include <QList>
26 
27 class KGrLevelGrid : public QObject
28 {
29  Q_OBJECT
30 public:
31  KGrLevelGrid (QObject * parent, const KGrRecording * theLevelData);
32  ~KGrLevelGrid();
33 
34  inline char cellType (int i, int j) {
35  return layout [i + j * width];
36  }
37 
38  inline Flags heroMoves (int i, int j) {
39  return heroAccess [i + j * width];
40  }
41 
42  inline Flags enemyMoves (int i, int j) {
43  return enemyAccess [i + j * width];
44  }
45 
46  inline void gotGold (const int i, const int j, const bool runnerHasGold) {
47  layout [i + j * width] = (runnerHasGold) ? FREE : NUGGET;
48  }
49 
50  inline int enemyOccupied (int i, int j) {
51  return enemyHere [i + j * width];
52  }
53 
54  inline void setEnemyOccupied (int i, int j, const int spriteId) {
55  enemyHere [i + j * width] = spriteId;
56  }
57 
58  void calculateAccess (bool pRunThruHole);
59 
60  void changeCellAt (const int i, const int j, const char type);
61 
62  void placeHiddenLadders();
63 
64 signals:
65  void showHiddenLadders (const QList<int> & ladders, const int width);
66 
67 private:
68  inline int index (int i, int j) {
69  return (i + j * width);
70  }
71 
72  void calculateCellAccess (const int i, const int j);
73 
74  int width;
75  int height;
76 
77  bool runThruHole; // Rule: Whether enemies run L/R through a hole.
78 
79  QVector<char> layout;
80  QVector<Flags> heroAccess;
81  QVector<Flags> enemyAccess;
82  QVector<int> enemyHere;
83 
84  QList<int> hiddenLadders;
85  QList<int> hiddenEnemies;
86  QList<int> flashingGold;
87 };
88 
89 #endif // KGRLEVELGRID_H
KGrLevelGrid::enemyOccupied
int enemyOccupied(int i, int j)
Definition: kgrlevelgrid.h:50
KGrLevelGrid::heroMoves
Flags heroMoves(int i, int j)
Definition: kgrlevelgrid.h:38
KGrLevelGrid::placeHiddenLadders
void placeHiddenLadders()
Definition: kgrlevelgrid.cpp:197
KGrLevelGrid::cellType
char cellType(int i, int j)
Definition: kgrlevelgrid.h:34
KGrLevelGrid::KGrLevelGrid
KGrLevelGrid(QObject *parent, const KGrRecording *theLevelData)
Definition: kgrlevelgrid.cpp:20
KGrLevelGrid
Definition: kgrlevelgrid.h:27
KGrLevelGrid::calculateAccess
void calculateAccess(bool pRunThruHole)
Definition: kgrlevelgrid.cpp:87
KGrLevelGrid::enemyMoves
Flags enemyMoves(int i, int j)
Definition: kgrlevelgrid.h:42
KGrLevelGrid::changeCellAt
void changeCellAt(const int i, const int j, const char type)
Definition: kgrlevelgrid.cpp:113
KGrLevelGrid::setEnemyOccupied
void setEnemyOccupied(int i, int j, const int spriteId)
Definition: kgrlevelgrid.h:54
NUGGET
const char NUGGET
Definition: kgrglobals.h:37
QObject
KGrRecording
KGrRecording structure: contains a record of play in a KGoldrunner level.
Definition: kgrglobals.h:115
KGrLevelGrid::~KGrLevelGrid
~KGrLevelGrid()
Definition: kgrlevelgrid.cpp:72
QList< int >
QVector< char >
kgrglobals.h
KGrLevelGrid::gotGold
void gotGold(const int i, const int j, const bool runnerHasGold)
Definition: kgrlevelgrid.h:46
KGrLevelGrid::showHiddenLadders
void showHiddenLadders(const QList< int > &ladders, const int width)
Flags
char Flags
Definition: kgrglobals.h:172
QObject::parent
QObject * parent() const
FREE
const char FREE
Definition: kgrglobals.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:24 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kgoldrunner

Skip menu "kgoldrunner"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal