blob: 85b12e293d9e1be174f172466454cfed1500062e (
plain)
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
|
//
//
// KBlackBox
//
// A simple game inspired by an emacs module
//
// File: kbbgame.h
//
// The definition of the KBBGame widget
//
#ifndef KBBGAME_H
#define KBBGAME_H
#include "kbbgfx.h"
#include "util.h"
#include <kmainwindow.h>
#include <krandomsequence.h>
class KSelectAction;
class KToggleAction;
/*
Types of the boxes (used f.e.g. in the traceRay() method)
*/
#define OUTERBBT 0
#define INNERBBT 1
#define LASERBBT 2
#define BALLBBT 3
/*
Ray-tracing results.
*/
#define WRONGSTART -1
#define DETOUR 0
#define REFLECTION 1
#define HIT 2
/*
* Statusbar IDs.
*/
#define SSCORE 0
#define SBALLS 1
#define SRUN 2
#define SSIZE 3
class KBBGame : public KMainWindow
{
Q_OBJECT
public:
KBBGame();
~KBBGame();
signals:
void gameRuns( bool );
private slots:
void slotSize();
void slotBalls();
void tutorialSwitch();
void newGame();
bool setSize( int w, int h );
bool setBalls( int n );
void setMinSize();
void randomBalls( int n );
void slotResize();
void gameResize();
void setScore( int n );
void updateStats();
void gameFinished();
void abortGame();
void giveUp();
void gotInputAt( int col, int row, int state );
private:
int traceRay( int startX, int startY, int *endX, int *endY );
void remap( RectOnArray *gam, RectOnArray *gra );
void getResults();
void initKAction();
int balls;
int detourCounter;
int ballsPlaced;
bool running;
bool tutorial;
RectOnArray *gameBoard;
KBBGraphic *gr;
int score;
/* TQLabel *scoreText;
TQLabel *statusText;*/
KRandomSequence random;
KSelectAction *ballsAction, *sizeAction;
KToggleAction *tutorialAction;
};
#endif // KBBGAME_H
|