source: trunk/tutorial/t12/cannon.h@ 10

Last change on this file since 10 was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1/****************************************************************
2**
3** Definition of CannonField class, Qt tutorial 12
4**
5****************************************************************/
6
7#ifndef CANNON_H
8#define CANNON_H
9
10class QTimer;
11
12
13#include <qwidget.h>
14
15
16class CannonField : public QWidget
17{
18 Q_OBJECT
19public:
20 CannonField( QWidget *parent=0, const char *name=0 );
21
22 int angle() const { return ang; }
23 int force() const { return f; }
24 QSizePolicy sizePolicy() const;
25
26public slots:
27 void setAngle( int degrees );
28 void setForce( int newton );
29 void shoot();
30 void newTarget();
31
32private slots:
33 void moveShot();
34
35signals:
36 void hit();
37 void missed();
38 void angleChanged( int );
39 void forceChanged( int );
40
41protected:
42 void paintEvent( QPaintEvent * );
43
44private:
45 void paintShot( QPainter * );
46 void paintTarget( QPainter * );
47 void paintCannon( QPainter * );
48 QRect cannonRect() const;
49 QRect shotRect() const;
50 QRect targetRect() const;
51
52 int ang;
53 int f;
54
55 int timerCount;
56 QTimer * autoShootTimer;
57 float shoot_ang;
58 float shoot_f;
59
60 QPoint target;
61};
62
63
64#endif // CANNON_H
Note: See TracBrowser for help on using the repository browser.