00001 /********************************************************************** 00002 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 00003 ** 00004 ** This file is part of Qtopia Environment. 00005 ** 00006 ** This file may be distributed and/or modified under the terms of the 00007 ** GNU General Public License version 2 as published by the Free Software 00008 ** Foundation and appearing in the file LICENSE.GPL included in the 00009 ** packaging of this file. 00010 ** 00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 ** 00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00015 ** 00016 ** Contact info@trolltech.com if any conditions of this licensing are 00017 ** not clear to you. 00018 ** 00019 **********************************************************************/ 00020 #include <qmainwindow.h> 00021 #include <qpe/qpeapplication.h> 00022 #include <qcanvas.h> 00023 #include <qlabel.h> 00024 00025 #include "snake.h" 00026 #include "target.h" 00027 #include "obstacle.h" 00028 00029 // class QCanvas; 00030 00031 class SnakeGame : public QMainWindow { 00032 Q_OBJECT 00033 00034 public: 00035 SnakeGame(QWidget* parent=0, const char* name=0, WFlags f=0); 00036 ~SnakeGame(); 00037 00038 void clear(); 00039 void createTargets(); 00040 00041 static QString appName() { return QString::fromLatin1("snake"); } 00042 00043 protected: 00044 virtual void keyPressEvent(QKeyEvent*); 00045 virtual void resizeEvent(QResizeEvent *e); 00046 00047 signals: 00048 void moveFaster(); 00049 00050 private slots: 00051 void newGame(); 00052 void gameOver(); 00053 void wait(); 00054 void levelUp(); 00055 void scoreInc(); 00056 void welcomescreen(); 00057 00058 private: 00059 void showScore(int); 00060 QCanvasView* cv; 00061 QLabel* scorelabel; 00062 QCanvas canvas; 00063 QTimer* pauseTimer; 00064 Snake* snake; 00065 int last; 00066 int level; 00067 int stage; 00068 int targetamount; 00069 int notargets; 00070 bool waitover; 00071 bool gamestopped; 00072 };
1.4.2