summaryrefslogtreecommitdiff
path: root/noncore/games/sfcave/sfcave.h
blob: 69a0e136c1d7df8dacd7ba4aaaa6d39929828d5d (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
105
106
107
108
#include <qmainwindow.h>
#include <qpainter.h>
#include <qpixmap.h>
#include <qpoint.h>
#include <qrect.h>
#include <qtimer.h>



#define MAPSIZE 52
#define BLOCKSIZE 6
#define TRAILSIZE 30

class SFCave : public QMainWindow
{
Q_OBJECT

public:
	int sWidth;
	int sHeight;
	int segSize;

	int blockWidth;
	int blockHeight;
    int gapHeight;
	int state;
	int prevState;
	int speed;
    int crashLineLength;

    static double UpThrustVals[3][3];
    static double DownThrustVals[3][3];
    static double MaxUpThrustVals[3][3];
    static double MaxDownThrustVals[3][3];
    static int initialGateGaps[];
    
    double thrustUp;
    double noThrust;
    double maxUpThrust;
    double maxDownThrust;

    int gateDistance;
    int nextGate;
    int lastGateBottomY;
    
    static QString menuOptions[2][5];
    int currentMenuNr;
    static int nrMenuOptions[2];
    static int currentMenuOption[2];

    static QString dificultyOption[3];
    static QString gameTypes[3];
    int currentGameType;
    int currentGameDifficulty;

	QPixmap *offscreen;
	QTimer *gameTimer;

	int score;
	int highestScore[3][3];

	int mapTop[MAPSIZE];
	int mapBottom[MAPSIZE];
	QRect blocks[BLOCKSIZE];
	QRect user;
	QPoint trail[TRAILSIZE];

	int offset;
	int maxHeight;
	int nrFrames;
	int dir;

	bool showScoreZones;

	bool press;
	double thrust;
	bool running;

	SFCave( int speed = 3, QWidget *p = 0, char *name = 0 );
	~SFCave();
	void start();
	int nextInt( int range );
	void setUp();
    void handleGameSFCave();
    void handleGameGates();
    void handleGameFly();
	bool checkFlyGameCollision();
	void moveFlyGameLandscape();
	void setFlyPoint( int point );
	bool checkCollision();
	void moveLandscape();
	void addBlock();
	void addGate();
	void setPoint( int point );
	void drawBoss();
	void draw();
	void handleKeys();

    void displayMenu();
    void dealWithMenuSelection();

	void keyPressEvent( QKeyEvent *e );
	void keyReleaseEvent( QKeyEvent *e );
    void saveScore();

private slots:
	void run();
};