Last change
on this file since 137 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 |
|
---|
10 | class QTimer;
|
---|
11 |
|
---|
12 |
|
---|
13 | #include <qwidget.h>
|
---|
14 |
|
---|
15 |
|
---|
16 | class CannonField : public QWidget
|
---|
17 | {
|
---|
18 | Q_OBJECT
|
---|
19 | public:
|
---|
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 |
|
---|
26 | public slots:
|
---|
27 | void setAngle( int degrees );
|
---|
28 | void setForce( int newton );
|
---|
29 | void shoot();
|
---|
30 | void newTarget();
|
---|
31 |
|
---|
32 | private slots:
|
---|
33 | void moveShot();
|
---|
34 |
|
---|
35 | signals:
|
---|
36 | void hit();
|
---|
37 | void missed();
|
---|
38 | void angleChanged( int );
|
---|
39 | void forceChanged( int );
|
---|
40 |
|
---|
41 | protected:
|
---|
42 | void paintEvent( QPaintEvent * );
|
---|
43 |
|
---|
44 | private:
|
---|
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.