• Skip to content
  • Skip to link menu
KDE 4.2 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 
00037 class KGrFigure : public QObject
00038 {
00039     Q_OBJECT
00040 public:
00044     KGrFigure (int, int);
00045     virtual ~KGrFigure();
00046 
00047     // STATIC GLOBAL FLAGS.
00048     static bool variableTiming;     
00049     static bool alwaysCollectNugget;    
00050     static bool runThruHole;        
00051     static bool reappearAtTop;      
00052     static SearchStrategy searchStrategy; 
00053 
00054     static Timing fixedTiming;      
00055 
00056     static Timing varTiming [6];    
00057 
00058     int getx();
00059     int gety();
00060     Status getStatus();
00061 
00062     int getnuggets();
00063     void setNuggets (int n);
00064     void setPlayfield (KGrObject *(*p)[30][22]);
00065     void showFigure(); //zeigt Figur
00066     virtual void init (int,int);
00067     void eraseOldFigure();
00068 
00069 signals:
00070     void stepDone (bool hanging);
00071     void falling (bool startStop);
00072 
00073 protected:
00074     // STATIC GLOBAL VARIABLES.
00075     static int herox;
00076     static int heroy;
00077 
00078     static int speed;           // Adjustable game-speed factor.
00079 
00080     int x, y;
00081     int absx, absy;
00082     int relx, rely;         // Relative movement, in pixels.
00083     int mem_x,mem_y,mem_relx,mem_rely;
00084     int walkCounter;
00085     int nuggets;
00086     int actualPixmap;           // Array index of the pixmap to draw.
00087     bool alternateStepGraphics;
00088     QTimer *walkTimer;
00089     QTimer *fallTimer;
00090 
00091     KGrObject *(*playfield)[30][22];
00092     Status status;
00093     Direction direction;
00094     bool canWalkRight();
00095     bool canWalkLeft();
00096     virtual bool canWalkUp();
00097     bool canWalkDown();
00098     bool canStand();
00099     bool hangAtPole();
00100     virtual bool standOnEnemy()=0;
00101     void walkUp (int);
00102     void walkDown (int, int);
00103     void walkRight (int, int);
00104     void walkLeft (int, int);
00105     void initFall (int, int);
00106 
00107     bool walkFrozen;
00108     bool fallFrozen;
00109 };
00110 
00114 class KGrHero : public KGrFigure
00115 {
00116     Q_OBJECT
00117 public:
00118     KGrHero (KGrCanvas *, int , int);
00119     virtual ~KGrHero();
00120     bool started;
00121     void showFigure();
00122     void dig();
00123     void digLeft();
00124     void digRight();
00125     void startWalk();
00126     void setEnemyList (QList<KGrEnemy *> *);
00127     void init (int,int);
00128     void setKey (Direction);
00129     void setDirection (int, int);
00130     void start();
00131     void loseNugget();
00132     static int WALKDELAY;
00133     static int FALLDELAY;
00134     void setSpeed (int);
00135     void doStep();
00136     void showState (char);
00137 
00138 private:
00139     QList<KGrEnemy *> *enemies;
00140     KGrCanvas * heroView;
00141     bool standOnEnemy();
00142     bool isInEnemy();
00143     bool isInside (int, int);
00144 
00145     Direction nextDir;
00146     void collectNugget();
00147 
00148     bool mouseMode;
00149     bool stopped;
00150     int mousex;
00151     int mousey;
00152     void setNextDir();
00153 
00154 public slots:
00155     void walkTimeDone();
00156     void fallTimeDone();
00157 
00158 signals:
00159     void gotNugget (int);
00160     void digs();
00161     void haveAllNuggets();
00162     void leaveLevel();
00163     void caughtHero();
00164 };
00165 
00169 class KGrEnemy : public KGrFigure
00170 {
00171     Q_OBJECT
00172 public:
00173     KGrEnemy (KGrCanvas *, int , int);
00174     virtual ~KGrEnemy();
00175     void showFigure();
00176     void startSearching();
00177     void setEnemyList (QList<KGrEnemy *> *);
00178     virtual void init (int,int);
00179     static int WALKDELAY;
00180     static int FALLDELAY;
00181     static int CAPTIVEDELAY;
00182     int enemyId;
00183     void doStep();
00184     void showState (char);
00185 
00186     static void makeReappearanceSequence();
00187 
00188 private:
00189     KGrCanvas * enemyView;
00190     int birthX, birthY;
00191     int searchStatus;
00192     int captiveCounter;
00193     QTimer *captiveTimer;
00194     bool canWalkUp();
00195     QList<KGrEnemy *> *enemies;
00196     bool standOnEnemy();
00197     bool bumpingFriend();
00198 
00199     void startWalk();
00200 
00201     static int reappearIndex;
00202     static int reappearPos [FIELDWIDTH];
00203     void dieAndReappear();
00204     Direction searchbestway (int,int,int,int);
00205     Direction searchdownway (int,int);
00206     Direction searchupway (int,int);
00207     Direction searchleftway (int,int);
00208     Direction searchrightway (int,int);
00209 
00210     Direction lowSearchUp (int,int,int);
00211     Direction lowSearchDown (int,int,int);
00212     Direction lowGetHero (int,int,int);
00213 
00214     int  distanceUp (int, int, int);
00215     int  distanceDown (int, int, int);
00216     bool searchOK (int, int, int);
00217     int  canWalkLR (int, int, int);
00218     bool willNotFall (int, int);
00219 
00220     void collectNugget();
00221     void dropNugget();
00222 
00223     bool captiveFrozen;
00224 
00225 public slots:
00226     void walkTimeDone();
00227     void fallTimeDone();
00228     void captiveTimeDone();
00229 
00230 signals:
00231     void lostNugget();
00232     void trapped (int);
00233     void killed (int);
00234 };
00235 
00236 #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