Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

view.h

Go to the documentation of this file.
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  * KAsteroids - Copyright (c) Martin R. Jones 1997
00021  *
00022  * Part of the KDE project
00023  */
00024 
00025 #ifndef __AST_VIEW_H__
00026 #define __AST_VIEW_H__
00027 
00028 #include <qwidget.h>
00029 #include <qlist.h>
00030 #include <qintdict.h>
00031 #include <qtimer.h>
00032 #include <qcanvas.h>
00033 #include "sprites.h"
00034 
00035 #define QPtrList QList
00036 #define QPtrListIterator QListIterator
00037 
00038 #define MAX_POWER_LEVEL          1000
00039 
00040 class KAsteroidsView : public QWidget
00041 {
00042     Q_OBJECT
00043 public:
00044     KAsteroidsView( QWidget *parent = 0, const char *name = 0 );
00045     virtual ~KAsteroidsView();
00046 
00047     int refreshRate;
00048 
00049     void reset();
00050     void setRockSpeed( double rs ) { rockSpeed = rs; }
00051     void addRocks( int num );
00052     void newGame();
00053     void endGame();
00054     void newShip();
00055 
00056     void rotateLeft( bool r ) { rotateL = r; rotateSlow = 5; }
00057     void rotateRight( bool r ) { rotateR = r; rotateSlow = 5; }
00058     void thrust( bool t ) { thrustShip = t && shipPower > 0; }
00059     void shoot( bool s ) { shootShip = s; shootDelay = 0; }
00060     void setShield( bool s );
00061     void teleport( bool te) { teleportShip = te && mTeleportCount; }
00062     void brake( bool b );
00063     void pause( bool p);
00064 
00065     void showText( const QString &text, const QColor &color, bool scroll=TRUE );
00066     void hideText();
00067 
00068     int shots() const { return shotsFired; }
00069     int hits() const { return shotsHit; }
00070     int power() const { return shipPower; }
00071 
00072     int teleportCount() const { return mTeleportCount; }
00073     int brakeCount() const { return mBrakeCount; }
00074     int shieldCount() const { return mShieldCount; }
00075     int shootCount() const { return mShootCount; }
00076 
00077 signals:
00078     void shipKilled();
00079     void rockHit( int size );
00080     void rocksRemoved();
00081     void updateVitals();
00082 
00083 private slots:
00084     void hideShield();
00085 
00086 protected:
00087     void readSprites();
00088     void wrapSprite( QCanvasItem * );
00089     void rockHit( QCanvasItem * );
00090     void reducePower( int val );
00091     void addExhaust( double x, double y, double dx, double dy, int count );
00092     void processMissiles();
00093     void processShip();
00094     void processPowerups();
00095     void processShield();
00096     double randDouble();
00097     int randInt( int range );
00098 
00099     virtual void resizeEvent( QResizeEvent *event );
00100     virtual void timerEvent( QTimerEvent * );
00101 
00102 private:
00103     QCanvas field;
00104     QCanvasView view;
00105     QIntDict<QCanvasPixmapArray> animation;
00106     QPtrList<QCanvasSprite> rocks;
00107     QPtrList<KMissile> missiles;
00108     QPtrList<KBit> bits;
00109     QPtrList<KExhaust> exhaust;
00110     QPtrList<KPowerup> powerups;
00111     KShield *shield;
00112     QCanvasSprite *ship;
00113     QCanvasText *textSprite;
00114 
00115     bool rotateL;
00116     bool rotateR;
00117     bool thrustShip;
00118     bool shootShip;
00119     bool teleportShip;
00120     bool brakeShip;
00121     bool pauseShip;
00122     bool shieldOn;
00123 
00124     bool vitalsChanged;
00125 
00126     int  shipAngle;
00127     int  rotateSlow;
00128     int  rotateRate;
00129     int  shipPower;
00130 
00131     int shotsFired;
00132     int shotsHit;
00133     int shootDelay;
00134 
00135     int mBrakeCount;
00136     int mShieldCount;
00137     int mTeleportCount;
00138     int mShootCount;
00139 
00140     double shipDx;
00141     double shipDy;
00142 
00143     int  textDy;
00144     int  mFrameNum;
00145     bool mPaused;
00146     int  mTimerId;
00147 
00148     double rockSpeed;
00149     double powerupSpeed;
00150 
00151     bool can_destroy_powerups;
00152 
00153     QTimer *shieldTimer;
00154 };
00155 
00156 #endif

Generated on Sat Nov 5 16:15:54 2005 for OPIE by  doxygen 1.4.2