• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kgoldrunner

kgrcanvas.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                          kgrcanvas.h  -  description
00003                              -------------------
00004     begin                : Wed Jan 23 2002
00005     Copyright 2002 Marco Krüger <grisuji@gmx.de>
00006     Copyright 2002 Ian Wadham <ianw2@optusnet.com.au>
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
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> // IDW
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;       // Set AFTER the initial resize events.
00114 
00115     QCursor * m;            // Mouse cursor.
00116     KGrPlayField * playfield;       // Array of tiles where runners can run.
00117 
00118     int scaleStep;          // Current scale-factor of canvas.
00119     int baseScale;          // Starting scale-factor of canvas.
00120     int baseFontSize;
00121 
00122     int nCellsW;            // Number of tiles horizontally.
00123     int nCellsH;            // Number of tiles vertically.
00124     int border;             // Number of tiles allowed for border.
00125     int lineDivider;            // Fraction of a tile for inner border.
00126     QPoint topLeft;         // Top left point of the tile array.
00127 
00128     QLabel * title;         // Title and top part of border.
00129 
00130     int bgw, bgh;           // Size of KGoldrunner 2 tile QPixmap.
00131     int imgW, imgH;         // Scaled size of KGr 3 tile QImage.
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     // IDW - Temporary ... should use a more general playfield (grid) idea.
00157     KGrTheme::TileType tileNo [FIELDWIDTH] [FIELDHEIGHT];
00158     unsigned char randomOffsets [FIELDWIDTH] [FIELDHEIGHT];
00159 
00160     int resizeCount;            // =0 until the main window has resized.
00161     QTime t; // IDW
00162     unsigned int level;
00163     
00164     // Keep current score and lives 
00165     int lives;
00166     int score;
00167 };
00168 #endif // KGRCANVAS_H
00169 // vi: set sw=4 :

kgoldrunner

Skip menu "kgoldrunner"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

API Reference

Skip menu "API Reference"
  • kblackbox
  • kgoldrunner
  • kmahjongg
  • ksquares
  • libkdegames
  •   highscore
  •   kgame
  •   kggzgames
  •   kggzmod
  •   kggznet
  • libkmahjongg
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal