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