00001 #include <qmainwindow.h> 00002 #include <qpainter.h> 00003 #include <qpixmap.h> 00004 #include <qpoint.h> 00005 #include <qrect.h> 00006 #include <qtimer.h> 00007 #include <qlist.h> 00008 00009 #include "random.h" 00010 00011 #define MAPSIZE 52 00012 #define BLOCKSIZE 6 00013 #define TRAILSIZE 30 00014 00015 #define NR_MENUS 3 00016 #define MAX_MENU_OPTIONS 8 00017 00018 class SFCave : public QMainWindow 00019 { 00020 Q_OBJECT 00021 00022 public: 00023 int sWidth; 00024 int sHeight; 00025 int segSize; 00026 00027 int currentSeed; 00028 00029 QList<int> replayList; 00030 QListIterator<int> *replayIt; 00031 bool replay; 00032 QString replayFile; 00033 00034 int blockWidth; 00035 int blockHeight; 00036 int gapHeight; 00037 int state; 00038 int prevState; 00039 int speed; 00040 int crashLineLength; 00041 bool startScoring; 00042 bool showEyeCandy; 00043 00044 static double UpThrustVals[3][3]; 00045 static double DownThrustVals[3][3]; 00046 static double MaxUpThrustVals[3][3]; 00047 static double MaxDownThrustVals[3][3]; 00048 static int initialGateGaps[]; 00049 00050 static int flyEasyScores[7][3]; 00051 static int flyNormalScores[7][3]; 00052 static int flyHardScores[7][3]; 00053 int *flyScores; 00054 00055 00056 double thrustUp; 00057 double noThrust; 00058 double maxUpThrust; 00059 double maxDownThrust; 00060 00061 int gateDistance; 00062 int nextGate; 00063 int lastGateBottomY; 00064 00065 static QString menuOptions[NR_MENUS][MAX_MENU_OPTIONS]; 00066 int currentMenuNr; 00067 static int nrMenuOptions[NR_MENUS]; 00068 static int currentMenuOption[NR_MENUS]; 00069 00070 static QString dificultyOption[3]; 00071 static QString gameTypes[3]; 00072 int currentGameType; 00073 int currentGameDifficulty; 00074 00075 QPixmap *offscreen; 00076 QTimer *gameTimer; 00077 00078 int score; 00079 int highestScore[3][3]; 00080 00081 int mapTop[MAPSIZE]; 00082 int mapBottom[MAPSIZE]; 00083 QRect blocks[BLOCKSIZE]; 00084 QRect user; 00085 QPoint trail[TRAILSIZE]; 00086 00087 int offset; 00088 int maxHeight; 00089 int nrFrames; 00090 int dir; 00091 00092 bool showScoreZones; 00093 00094 bool press; 00095 double thrust; 00096 bool running; 00097 00098 SFCave( QWidget *p = 0, const char *name = 0, WFlags fl = 0 ); 00099 ~SFCave(); 00100 00101 static QString appName() { return QString::fromLatin1( QUICKAPP_NAME ); } 00102 00103 public slots: 00104 void start(); 00105 public: 00106 00107 void setSeed( int seed ); 00108 int nextInt( int range ); 00109 void setUp(); 00110 void handleGameSFCave(); 00111 void handleGameGates(); 00112 void handleGameFly(); 00113 bool checkFlyGameCollision(); 00114 void moveFlyGameLandscape(); 00115 void setFlyPoint( int point ); 00116 bool checkCollision(); 00117 void moveLandscape(); 00118 void addBlock(); 00119 void addGate(); 00120 void setPoint( int point ); 00121 void drawBoss(); 00122 void draw(); 00123 void handleKeys(); 00124 00125 void handleMenuKeys( QKeyEvent * e ); 00126 void displayMenu(); 00127 void dealWithMenuSelection(); 00128 00129 void keyPressEvent( QKeyEvent *e ); 00130 void keyReleaseEvent( QKeyEvent *e ); 00131 void saveScore(); 00132 void saveReplay(); 00133 void loadReplay(); 00134 00135 private slots: 00136 void run(); 00137 };
1.4.2