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