kgoldrunner
#include <kgrrunner.h>
Public Member Functions | |
KGrEnemy (KGrLevelPlayer *pLevelPlayer, KGrLevelGrid *pGrid, int i, int j, int pSpriteId, KGrRuleBook *pRules) | |
~KGrEnemy () | |
Direction | direction () |
int | getPrevInCell () |
bool | isFalling () |
void | run (const int scaledTime) |
void | setPrevInCell (const int prevEnemy) |
void | showState () |
Public Member Functions inherited from KGrRunner | |
KGrRunner (KGrLevelPlayer *pLevelPlayer, KGrLevelGrid *pGrid, int i, int j, const int pSpriteId, KGrRuleBook *pRules, const int startDelay) | |
virtual | ~KGrRunner () |
int | whereAreYou (int &x, int &y) |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QObject (QObject *parent, const char *name) | |
virtual | ~QObject () |
bool | blockSignals (bool block) |
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const |
const QObjectList & | children () const |
const char * | className () const |
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const QObject *receiver, const char *method) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QByteArray > | dynamicPropertyNames () const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name) const |
QList< T > | findChildren (const QRegExp ®Exp) const |
QList< T > | findChildren (const QString &name) const |
bool | inherits (const char *className) const |
void | insertChild (QObject *object) |
void | installEventFilter (QObject *filterObj) |
bool | isA (const char *className) const |
bool | isWidgetType () const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
const char * | name () const |
const char * | name (const char *defaultName) const |
QString | objectName () const |
QObject * | parent () const |
QVariant | property (const char *name) const |
void | removeChild (QObject *object) |
void | removeEventFilter (QObject *obj) |
void | setName (const char *name) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval) |
QThread * | thread () const |
Additional Inherited Members | |
Signals inherited from KGrRunner | |
void | incScore (const int n) |
void | startAnimation (const int spriteId, const bool repeating, const int i, const int j, const int time, const Direction dirn, const AnimationType type) |
Static Public Member Functions inherited from QObject | |
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Protected Member Functions inherited from KGrRunner | |
void | getRules () |
char | nextCell () |
bool | setNextMovement (const char spriteType, const char cellType, Direction &dir, AnimationType &anim, int &interval) |
Situation | situation (const int scaledTime) |
Protected Member Functions inherited from QObject | |
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method) |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const char *signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const char *signal) |
int | receivers (const char *signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Static Protected Member Functions inherited from QObject | |
QByteArray | normalizeSignalSlot (const char *signalSlot) |
Protected Attributes inherited from KGrRunner | |
AnimationType | currAnimation |
Direction | currDirection |
int | deltaX |
int | deltaY |
int | enemyFallTime |
bool | falling |
int | fallTime |
KGrLevelGrid * | grid |
int | gridI |
int | gridJ |
int | gridX |
int | gridY |
int | interval |
bool | leftRightSearch |
KGrLevelPlayer * | levelPlayer |
int | pointCtr |
int | pointsPerCell |
KGrRuleBook * | rules |
int | runTime |
int | spriteId |
QTime | t |
int | timeLeft |
int | trapTime |
bool | turnAnywhere |
Properties inherited from QObject | |
objectName | |
Detailed Description
This class models the behaviour of an enemy.
It inherits from KGrRunner.
An enemy's main functions are running, chasing the hero and collecting or dropping gold. If he comes to a dug brick, he must fall in and give up any gold he is carrying. If he is trapped in a closing brick, he dies but reappears elsewhere on the grid.
Definition at line 229 of file kgrrunner.h.
Constructor & Destructor Documentation
KGrEnemy::KGrEnemy | ( | KGrLevelPlayer * | pLevelPlayer, |
KGrLevelGrid * | pGrid, | ||
int | i, | ||
int | j, | ||
int | pSpriteId, | ||
KGrRuleBook * | pRules | ||
) |
The constructor of the KGrEnemy class.
- Parameters
-
pLevelPlayer The object that owns the enemy and will destroy him if the KGoldrunner application is terminated during play. The object also provides helper functions to the enemies. pGrid The grid on which the enemy is playing. i The starting column-number (>=1). j The starting row-number (>=1). pSpriteId The sprite ID of the enemy, as used in animation. pRules The rules that apply to this game and level. pRandomGen Random number generator: used to decide when to pick up or drop gold.
Definition at line 354 of file kgrrunner.cpp.
KGrEnemy::~KGrEnemy | ( | ) |
Definition at line 374 of file kgrrunner.cpp.
Member Function Documentation
|
inline |
Returns the direction in which the enemy is running: used for avoiding collisions with other enemies.
Definition at line 274 of file kgrrunner.h.
|
inline |
Returns the ID of an enemy who already occupied the same cell (or -1).
Definition at line 279 of file kgrrunner.h.
|
inline |
Returns true if the enemy is falling.
Definition at line 292 of file kgrrunner.h.
void KGrEnemy::run | ( | const int | scaledTime | ) |
Makes an enemy run, guided by the position of the hero and the layout of the grid.
The method is invoked by a periodic timer. If the enemy is trapped in a brick, he reappears somewhere else on the grid, depending on the rules for the game and level. While running, the enemy picks up and randomly drops gold. If he comes to a dug brick, he must fall in and give up any gold he is carrying. He can climb out after a time: or the hole might close first. Otherwise the method changes the enemy's position as required, avoids collisions and decides the type of animation to display (run left, climb, etc.).
- Parameters
-
scaledTime The amount by which to adjust the time, scaled according to the current game-speed setting. Smaller times cause slower running in real-time: larger times cause faster running.
Definition at line 378 of file kgrrunner.cpp.
|
inline |
Sets the ID of an enemy who already occupied the same cell (or -1).
- Parameters
-
prevEnemy The sprite ID of the previous enemy (or -1).
Definition at line 286 of file kgrrunner.h.
void KGrEnemy::showState | ( | ) |
Implements the author's debugging aid that shows the enemy's state.
Definition at line 610 of file kgrrunner.cpp.
The documentation for this class was generated from the following files:
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.