kgoldrunner
kgrcanvas.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef KGRCANVAS_H
00019 #define KGRCANVAS_H
00020
00021 #include <kgamecanvas.h>
00022
00023 #include "kgrplayfield.h"
00024 #include "kgrsprite.h"
00025 #include "kgrconsts.h"
00026
00027 #include <qcursor.h>
00028 #include <QLabel>
00029 #include <QImage>
00030 #include <QPixmap>
00031 #include <QMouseEvent>
00032 #include <QList>
00033 #include <QTime>
00034 #include <QTimeLine>
00035
00036 #include "kgrtheme.h"
00037
00038
00039 class KGrCanvas : public KGameCanvasWidget
00040 {
00041 Q_OBJECT
00042 public:
00043 KGrCanvas (QWidget * parent, const double scale,
00044 const QString & systemDataDir);
00045 virtual ~KGrCanvas();
00046
00047 QPoint getMousePos();
00048 void setMousePos (int, int);
00049
00050 void setBaseScale();
00051
00052 void paintCell (int, int, char, int offset = 0);
00053 void setTitle (const QString&);
00054
00055 void makeHeroSprite (int, int, int);
00056 void setHeroVisible (bool);
00057 void moveHero (int, int, int);
00058
00059 void makeEnemySprite (int, int, int);
00060 void moveEnemy (int, int, int, int, int);
00061 void deleteEnemySprites();
00062
00063 void goToBlack();
00064 void fadeIn();
00065 void fadeOut();
00066 void updateScore (int score);
00067 void updateLives (int lives);
00068
00069 QPixmap getPixmap (char type);
00070
00071 bool changeTheme (const QString & themeFilepath);
00076 void setLevel (unsigned int level);
00077
00078 signals:
00079 void mouseClick (int);
00080 void mouseLetGo (int);
00081 void fadeFinished();
00082
00083 protected:
00084 virtual void mousePressEvent (QMouseEvent * mouseEvent);
00085 virtual void mouseReleaseEvent (QMouseEvent * mouseEvent);
00086 virtual void resizeEvent (QResizeEvent * event);
00087 virtual QSize sizeHint() const;
00088
00089 private slots:
00090 void drawSpotLight (qreal value);
00091
00092 private:
00093 void initView();
00094
00098 void loadBackground();
00099
00100 void drawTheScene (bool changePixmaps);
00101 void makeBorder();
00102 void makeTitle();
00103 KGrTheme::TileType tileForType(char type);
00104 int tileNumber(KGrTheme::TileType type, int x, int y);
00105
00106 KGameCanvasRectangle * drawRectangle (int x, int y, int w, int h);
00107
00108 KGameCanvasPixmap * makeBorderElement (QList< QPixmap > frameTiles,
00109 int x, int y, int which);
00110
00111 KGameCanvasPixmap * makeDisplay (QList< QPixmap > tiles, int w);
00112
00113 bool firstSceneDrawn;
00114
00115 QCursor * m;
00116 KGrPlayField * playfield;
00117
00118 int scaleStep;
00119 int baseScale;
00120 int baseFontSize;
00121
00122 int nCellsW;
00123 int nCellsH;
00124 int border;
00125 int lineDivider;
00126 QPoint topLeft;
00127
00128 QLabel * title;
00129
00130 int bgw, bgh;
00131 int imgW, imgH;
00132 int oldImgW, oldImgH;
00133
00134 int goldEnemy;
00135
00136 KGameCanvasPicture *m_spotLight;
00137 KGameCanvasText *m_scoreText;
00138 KGameCanvasText *m_livesText;
00139 KGameCanvasPixmap * m_scoreDisplay;
00140 KGameCanvasPixmap * m_livesDisplay;
00141
00142 QTimeLine m_fadingTimeLine;
00143
00144 KGrSprite * heroSprite;
00145 QList<KGrSprite *> * enemySprites;
00146 QList<KGameCanvasRectangle *> borderRectangles;
00147 QList<KGameCanvasPixmap *> borderElements;
00148 QColor colour;
00149
00150 QList<QPixmap> * tileset;
00151
00152 QList<QPixmap> * heroFrames;
00153 QList<QPixmap> * enemyFrames;
00154 KGrTheme theme;
00155
00156
00157 KGrTheme::TileType tileNo [FIELDWIDTH] [FIELDHEIGHT];
00158 unsigned char randomOffsets [FIELDWIDTH] [FIELDHEIGHT];
00159
00160 int resizeCount;
00161 QTime t;
00162 unsigned int level;
00163
00164
00165 int lives;
00166 int score;
00167 };
00168 #endif // KGRCANVAS_H
00169