2012
|
1 |
/*
|
|
2 |
* Hedgewars, a free turn based strategy game
|
|
3 |
* Copyright (c) 2009 Kristian Lehmann <email@thexception.net>
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU General Public License as published by
|
|
7 |
* the Free Software Foundation; version 2 of the License
|
|
8 |
*
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
15 |
* along with this program; if not, write to the Free Software
|
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
17 |
*/
|
|
18 |
|
|
19 |
#ifndef BGWIDGET_H
|
|
20 |
#define BGWIDGET_H
|
|
21 |
|
|
22 |
#include <QWidget>
|
|
23 |
//#include <QGLWidget>
|
|
24 |
#include <QPainter>
|
|
25 |
#include <QTimer>
|
|
26 |
#include <QPaintEvent>
|
|
27 |
#include <QTime>
|
|
28 |
#include <QPoint>
|
|
29 |
|
|
30 |
#define SPRITE_MAX 12
|
|
31 |
|
|
32 |
#define ANIMATION_INTERVAL 40
|
|
33 |
|
|
34 |
class SpritePosition
|
|
35 |
{
|
|
36 |
public:
|
|
37 |
SpritePosition(QWidget * parent, int sh);
|
|
38 |
~SpritePosition();
|
|
39 |
private:
|
|
40 |
float fX;
|
|
41 |
float fY;
|
|
42 |
float fXMov;
|
|
43 |
float fYMov;
|
2377
|
44 |
int iAngle;
|
2012
|
45 |
QWidget * wParent;
|
|
46 |
int iSpriteHeight;
|
|
47 |
public:
|
|
48 |
void move();
|
|
49 |
void reset();
|
|
50 |
QPoint pos();
|
|
51 |
int getAngle();
|
|
52 |
void init();
|
|
53 |
};
|
|
54 |
|
|
55 |
class BGWidget : public QWidget
|
|
56 |
{
|
|
57 |
Q_OBJECT
|
|
58 |
public:
|
|
59 |
BGWidget(QWidget * parent);
|
|
60 |
~BGWidget();
|
|
61 |
void startAnimation();
|
|
62 |
void stopAnimation();
|
|
63 |
void init();
|
|
64 |
private:
|
|
65 |
QImage sprite;
|
|
66 |
QTimer * timerAnimation;
|
|
67 |
SpritePosition * spritePositions[SPRITE_MAX];
|
|
68 |
QImage * rotatedSprites[360];
|
|
69 |
protected:
|
|
70 |
void paintEvent(QPaintEvent * event);
|
|
71 |
private slots:
|
|
72 |
void animate();
|
|
73 |
};
|
|
74 |
|
|
75 |
#endif // BGWIDGET_H
|