1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
/***************************************************************************
* kgrfigure.h - description *
* ------------------- *
* Copyright (C) 2003 by Ian Wadham and Marco Kr�ger *
* email : See menu "Help, About KGoldrunner" *
* [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef KGRFIGURE_H
#define KGRFIGURE_H
// Obsolete - #include <iostream.h>
#include <iostream>
#include <tqimage.h>
#ifdef QT3
#include <tqptrlist.h>
#else
#include <tqlist.h>
#endif
#include <tqpainter.h>
#include <tqpixmap.h>
#include <tqtimer.h>
#include <tqwidget.h>
#include <stdlib.h> // f�r Zufallsfunktionen
class KGrCanvas;
class KGrObject;
class KGrEnemy;
class KGrFigure : public TQObject
{
Q_OBJECT
public:
KGrFigure (int, int);
virtual ~KGrFigure();
// STATIC GLOBAL FLAGS.
static bool variableTiming; // More enemies imply less speed.
static bool alwaysCollectNugget; // Enemies always collect nuggets.
static bool runThruHole; // Enemy can run L/R through dug hole.
static bool reappearAtTop; // Enemies are reborn at top of screen.
static SearchStrategy searchStrategy; // Low, medium or high difficulty.
static Timing fixedTiming; // Original set of 6 KGr timing values.
static Timing varTiming [6]; // Optional 6 sets of timing values,
// dependent on number of enemies.
int getx();
int gety();
Status getStatus();
int getnuggets();
void setNuggets(int n);
void setPlayfield(KGrObject *(*p)[30][22]);
void showFigure(); //zeigt Figur
virtual void init(int,int);
void eraseOldFigure();
protected:
// STATIC GLOBAL VARIABLES.
static int herox;
static int heroy;
static int speed; // Adjustable game-speed factor.
int x, y;
int absx, absy;
int relx, rely; // Figur wird um relx,rely Pixel verschoben
int mem_x,mem_y,mem_relx,mem_rely;
int walkCounter;
int nuggets;
int actualPixmap; // ArrayPos der zu zeichnenden Pixmap
TQTimer *walkTimer;
TQTimer *fallTimer;
KGrObject *(*playfield)[30][22];
Status status;
Direction direction;
bool canWalkRight();
bool canWalkLeft();
virtual bool canWalkUp();
bool canWalkDown();
bool canStand();
bool hangAtPole();
virtual bool standOnEnemy()=0;
void walkUp(int);
void walkDown(int, int);
void walkRight(int, int);
void walkLeft(int, int);
void initFall(int, int);
bool walkFrozen;
bool fallFrozen;
};
class KGrHero : public KGrFigure
{
Q_OBJECT
public:
KGrHero(KGrCanvas *, int , int);
virtual ~KGrHero();
bool started;
void showFigure();
void dig();
void digLeft();
void digRight();
void startWalk();
#ifdef QT3
void setEnemyList(TQPtrList<KGrEnemy> *);
#else
void setEnemyList(TQPtrList<KGrEnemy> *);
#endif
void init(int,int);
void setKey(Direction);
void setDirection(int, int);
void start();
void loseNugget();
static int WALKDELAY;
static int FALLDELAY;
void setSpeed(int);
void doStep();
void showState (char);
private:
#ifdef QT3
TQPtrList<KGrEnemy> *enemies;
#else
TQPtrList<KGrEnemy> *enemies;
#endif
KGrCanvas * heroView;
bool standOnEnemy();
bool isInEnemy();
bool isInside(int, int);
Direction nextDir;
void collectNugget();
bool mouseMode;
bool stopped;
int mousex;
int mousey;
void setNextDir();
public slots:
void walkTimeDone();
void fallTimeDone();
signals:
void gotNugget(int);
void haveAllNuggets();
void leaveLevel();
void caughtHero();
};
class KGrEnemy : public KGrFigure
{
Q_OBJECT
public:
KGrEnemy (KGrCanvas *, int , int);
virtual ~KGrEnemy();
void showFigure();
void startSearching();
#ifdef QT3
void setEnemyList(TQPtrList<KGrEnemy> *);
#else
void setEnemyList(TQPtrList<KGrEnemy> *);
#endif
virtual void init(int,int);
static int WALKDELAY;
static int FALLDELAY;
static int CAPTIVEDELAY;
int enemyId;
void doStep();
void showState (char);
private:
KGrCanvas * enemyView;
int birthX, birthY;
int searchStatus;
int captiveCounter;
TQTimer *captiveTimer;
bool canWalkUp();
#ifdef QT3
TQPtrList<KGrEnemy> *enemies;
#else
TQPtrList<KGrEnemy> *enemies;
#endif
bool standOnEnemy();
bool bumpingFriend();
void startWalk();
void dieAndReappear();
Direction searchbestway(int,int,int,int);
Direction searchdownway(int,int);
Direction searchupway(int,int);
Direction searchleftway(int,int);
Direction searchrightway(int,int);
Direction lowSearchUp(int,int,int);
Direction lowSearchDown(int,int,int);
Direction lowGetHero(int,int,int);
int distanceUp (int, int, int);
int distanceDown (int, int, int);
bool searchOK (int, int, int);
int canWalkLR (int, int, int);
bool willNotFall (int, int);
void collectNugget();
void dropNugget();
bool captiveFrozen;
public slots:
void walkTimeDone();
void fallTimeDone();
void captiveTimeDone();
signals:
void lostNugget();
void trapped(int);
void killed(int);
};
#endif // KGRFIGURE_H
|