summaryrefslogtreecommitdiffstats
path: root/main/dependencies/qt3/tutorial/t14/cannon.h
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-07-10 15:24:15 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-07-10 15:24:15 -0500
commit7d523fac5a54f8e695e56f4877fa852608465bc7 (patch)
treef74237f64a396d91997032df9bdf674492529c94 /main/dependencies/qt3/tutorial/t14/cannon.h
parent37e3f157c7d76f13de807fa66e36df209e1005fb (diff)
downloadtde-7d523fac5a54f8e695e56f4877fa852608465bc7.tar.gz
tde-7d523fac5a54f8e695e56f4877fa852608465bc7.zip
Add Qt3 development HEAD version
Diffstat (limited to 'main/dependencies/qt3/tutorial/t14/cannon.h')
-rw-r--r--main/dependencies/qt3/tutorial/t14/cannon.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/main/dependencies/qt3/tutorial/t14/cannon.h b/main/dependencies/qt3/tutorial/t14/cannon.h
new file mode 100644
index 000000000..1f46c7168
--- /dev/null
+++ b/main/dependencies/qt3/tutorial/t14/cannon.h
@@ -0,0 +1,79 @@
+/****************************************************************
+**
+** Definition of CannonField class, Qt tutorial 14
+**
+****************************************************************/
+
+#ifndef CANNON_H
+#define CANNON_H
+
+class QTimer;
+
+
+#include <qwidget.h>
+
+
+class CannonField : public QWidget
+{
+ Q_OBJECT
+public:
+ CannonField( QWidget *parent=0, const char *name=0 );
+
+ int angle() const { return ang; }
+ int force() const { return f; }
+ bool gameOver() const { return gameEnded; }
+ bool isShooting() const;
+ QSize sizeHint() const;
+ QSizePolicy sizePolicy() const;
+
+public slots:
+ void setAngle( int degrees );
+ void setForce( int newton );
+ void shoot();
+ void newTarget();
+ void setGameOver();
+ void restartGame();
+
+private slots:
+ void moveShot();
+
+signals:
+ void hit();
+ void missed();
+ void angleChanged( int );
+ void forceChanged( int );
+ void canShoot( bool );
+
+protected:
+ void paintEvent( QPaintEvent * );
+ void mousePressEvent( QMouseEvent * );
+ void mouseMoveEvent( QMouseEvent * );
+ void mouseReleaseEvent( QMouseEvent * );
+
+private:
+ void paintShot( QPainter * );
+ void paintTarget( QPainter * );
+ void paintBarrier( QPainter * );
+ void paintCannon( QPainter * );
+ QRect cannonRect() const;
+ QRect shotRect() const;
+ QRect targetRect() const;
+ QRect barrierRect() const;
+ bool barrelHit( const QPoint & ) const;
+
+ int ang;
+ int f;
+
+ int timerCount;
+ QTimer * autoShootTimer;
+ float shoot_ang;
+ float shoot_f;
+
+ QPoint target;
+
+ bool gameEnded;
+ bool barrelPressed;
+};
+
+
+#endif // CANNON_H