• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kgoldrunner

kgrfigure.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                       kgrfigure.h  -  description                       *
00003  *                           -------------------                           *
00004     Copyright 2003 Marco Krüger <grisuji@gmx.de>
00005     Copyright 2003 Ian Wadham <ianw2@optusnet.com.au>
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  ***************************************************************************/
00012 
00013 /*
00014  * Many thanks to Kevin Krammer and Alex Sopicki for translating the
00015  * original comments in this program code from German into English.
00016  */
00017 
00018 #ifndef KGRFIGURE_H
00019 #define KGRFIGURE_H
00020 
00021 // Obsolete - #include <iostream.h>
00022 #include <iostream>
00023 
00024 #include <QList>
00025 #include <QTimer>
00026 #include <stdlib.h>         // For random-number generator.
00027 
00028 #include "kgrconsts.h"
00029 
00030 class KGrCanvas;
00031 class KGrObject;
00032 class KGrEnemy;
00033 
00034 class KGrFigure : public QObject
00035 {
00036   Q_OBJECT
00037 public:
00038   KGrFigure (int, int);
00039   virtual ~KGrFigure();
00040 
00041   // STATIC GLOBAL FLAGS.
00042   static bool variableTiming;       // More enemies imply less speed.
00043   static bool alwaysCollectNugget;  // Enemies always collect nuggets.
00044   static bool runThruHole;      // Enemy can run L/R through dug hole.
00045   static bool reappearAtTop;        // Enemies are reborn at top of screen.
00046   static SearchStrategy searchStrategy; // Low, medium or high difficulty.
00047 
00048   static Timing fixedTiming;        // Original set of 6 KGr timing values.
00049 
00050   static Timing varTiming [6];      // Optional 6 sets of timing values,
00051                     // dependent on number of enemies.
00052   int getx();
00053   int gety();
00054   Status getStatus();
00055 
00056   int getnuggets();
00057   void setNuggets(int n);
00058   void setPlayfield(KGrObject *(*p)[30][22]);
00059   void showFigure(); //zeigt Figur
00060   virtual void init(int,int);
00061   void eraseOldFigure();
00062 
00063 protected:
00064   // STATIC GLOBAL VARIABLES.
00065   static int herox;
00066   static int heroy;
00067 
00068   static int speed;         // Adjustable game-speed factor.
00069 
00070   int x, y;
00071   int absx, absy;
00072   int relx, rely;           // Relative movement, in pixels.
00073   int mem_x,mem_y,mem_relx,mem_rely;
00074   int walkCounter;
00075   int nuggets;
00076   int actualPixmap;         // Array index of the pixmap to draw.
00077   bool alternateStepGraphics;
00078   QTimer *walkTimer;
00079   QTimer *fallTimer;
00080 
00081   KGrObject *(*playfield)[30][22];
00082   Status status;
00083   Direction direction;
00084   bool canWalkRight();
00085   bool canWalkLeft();
00086   virtual bool canWalkUp();
00087   bool canWalkDown();
00088   bool canStand();
00089   bool hangAtPole();
00090   virtual bool standOnEnemy()=0;
00091   void walkUp(int);
00092   void walkDown(int, int);
00093   void walkRight(int, int);
00094   void walkLeft(int, int);
00095   void initFall(int, int);
00096 
00097   bool walkFrozen;
00098   bool fallFrozen;
00099 };
00100 
00101 class KGrHero : public KGrFigure
00102 {
00103   Q_OBJECT
00104 public:
00105   KGrHero(KGrCanvas *, int , int);
00106   virtual ~KGrHero();
00107   bool started;
00108   void showFigure();
00109   void dig();
00110   void digLeft();
00111   void digRight();
00112   void startWalk();
00113   void setEnemyList(QList<KGrEnemy *> *);
00114   void init(int,int);
00115   void setKey(Direction);
00116   void setDirection(int, int);
00117   void start();
00118   void loseNugget();
00119   static int WALKDELAY;
00120   static int FALLDELAY;
00121   void setSpeed(int);
00122   void doStep();
00123   void showState (char);
00124 
00125 private:
00126   QList<KGrEnemy *> *enemies;
00127   KGrCanvas * heroView;
00128   bool standOnEnemy();
00129   bool isInEnemy();
00130   bool isInside(int, int);
00131 
00132   Direction nextDir;
00133   void collectNugget();
00134 
00135   bool mouseMode;
00136   bool stopped;
00137   int mousex;
00138   int mousey;
00139   void setNextDir();
00140 
00141 public slots:
00142   void walkTimeDone();
00143   void fallTimeDone();
00144 
00145 signals:
00146   void gotNugget(int);
00147   void haveAllNuggets();
00148   void leaveLevel();
00149   void caughtHero();
00150 };
00151 
00152 class KGrEnemy : public KGrFigure
00153 {
00154   Q_OBJECT
00155 public:
00156   KGrEnemy (KGrCanvas *, int , int);
00157   virtual ~KGrEnemy();
00158   void showFigure();
00159   void startSearching();
00160   void setEnemyList(QList<KGrEnemy *> *);
00161   virtual void init(int,int);
00162   static int WALKDELAY;
00163   static int FALLDELAY;
00164   static int CAPTIVEDELAY;
00165   int enemyId;
00166   void doStep();
00167   void showState (char);
00168 
00169   static void makeReappearanceSequence();
00170 
00171 private:
00172   KGrCanvas * enemyView;
00173   int birthX, birthY;
00174   int searchStatus;
00175   int captiveCounter;
00176   QTimer *captiveTimer;
00177   bool canWalkUp();
00178   QList<KGrEnemy *> *enemies;
00179   bool standOnEnemy();
00180   bool bumpingFriend();
00181 
00182   void startWalk();
00183 
00184   static int reappearIndex;
00185   static int reappearPos [FIELDWIDTH];
00186   void dieAndReappear();
00187   Direction searchbestway(int,int,int,int);
00188   Direction searchdownway(int,int);
00189   Direction searchupway(int,int);
00190   Direction searchleftway(int,int);
00191   Direction searchrightway(int,int);
00192 
00193   Direction lowSearchUp(int,int,int);
00194   Direction lowSearchDown(int,int,int);
00195   Direction lowGetHero(int,int,int);
00196 
00197   int  distanceUp (int, int, int);
00198   int  distanceDown (int, int, int);
00199   bool searchOK (int, int, int);
00200   int  canWalkLR (int, int, int);
00201   bool willNotFall (int, int);
00202 
00203   void collectNugget();
00204   void dropNugget();
00205 
00206   bool captiveFrozen;
00207 
00208 public slots:
00209   void walkTimeDone();
00210   void fallTimeDone();
00211   void captiveTimeDone();
00212 
00213 signals:
00214   void lostNugget();
00215   void trapped(int);
00216   void killed(int);
00217 };
00218 
00219 #endif // KGRFIGURE_H

kgoldrunner

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

API Reference

Skip menu "API Reference"
  • kblackbox
  • kgoldrunner
  • kmahjongg
  • ksquares
  • libkdegames
  •   highscore
  •   kgame
  •   kggzgames
  •   kggzmod
  •   kggznet
  • libkmahjongg
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal