⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 playfield.h

📁 Source code (C++) of the Icebloxx game for Symbian OS UIQ3.x
💻 H
字号:
/*
 * Copyright (C) 2002 Robert Ernst <robert.ernst@linux-solutions.at>
 *
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * See COPYING for GPL licensing information.
 *
 */

#ifndef __PLAYFIELD_HEADER__
#define __PLAYFIELD_HEADER__
#include <e32base.h>
#include <s32stor.h>
//#include <qwidget.h>
//#include <qpixmap.h>
//#include <qtimer.h>
#include "SpriteCollection.h"
class CFbsBitGc;
class CIceBloxxView;
class CFbsBitmapDevice;
static const int max_lives = 6;
static const int max_flames = 4;
static const int max_blocks = 17;
static const int max_walls = 10;
static const int max_actors = max_flames + max_blocks + max_walls + 1;
static const int max_cols = 8;
static const int max_rows = 8;
static const int max_config = 6;

class QPaintEvent
{
public:
};


class QWidget:public CBase
{
	public:
		void repaint(bool /*aErase*/){ paintEvent(NULL);};
		virtual void paintEvent(QPaintEvent * /*event*/){};
};


enum TKeyStates
{
	Key_Up,
	Key_Down,
	Key_Left,
	Key_Right,
	Key_Space =32,
	Key_Enter = 13,
	Key_Escape = 27
};
class QKeyEvent
{
public:
	TInt key(){return iKey;};
	TInt iKey;
};

class QMouseEvent
{
public:
	TInt x(){return iX;};
	TInt y(){return iY;};
	TInt iX;
	TInt iY;
};
#include "soundhandler.h"
class PlayField : public QWidget
{
public:
    PlayField(CIceBloxxView *aParent, const char *name=NULL, TInt f=0);
    ~PlayField();
	void InternalizeL(RDictionaryReadStream& aReadStream);
	void ExternalizeL(RDictionaryWriteStream& aWriteStream) const;


private:
   
    enum Types {
	Empty = 0,
	Player,
	Block,
	BlockCoin,
	Flame,
	Points,
	Wall,
    };
    enum Directions {
	Stop = 0,
	Up,
	Down,
	Left,
	Right,
    };

private:
    SpriteCollection *m_sprites;
    CPeriodic *m_timer;
    QPixmap *m_pixmap;
	CFbsBitGc* m_pixgc;
	CFbsBitmapDevice* m_pixdevice;
    int m_speed;
    int m_strength;
    int m_coins;
    enum {
	Intro_1,
	Intro_2,
	Intro_3,
	HiScore,
	Playing,
	Dying,
	HappyPenguin,
	GameOver,
    } m_state;
    int m_counter;
    int m_score;
    int m_lives;
    int m_levels_completed;
    int m_blocks_broken;
    int m_coins_collected;
    int m_flames_killed;
    struct {
	int m_x;
	int m_y;
	enum Directions m_act_dir;
	enum Directions m_req_dir;
	int m_speed;
	int m_counter;
	enum Types m_type;
    } m_actor[max_actors];
    int m_actors;
    int m_coins_in_level;
    int m_click_x;
    int m_click_y;
#ifdef CAN_TELEPORT
    bool m_teleport;
#endif
	CIceBloxxView* iView;
public:
    void updateSpeed(int speed);
    void updateStrength(int strength);
    void updateCoins(int coins);
    void start(void);
    void stop(void);
	static TInt StaticTimerTick(TAny* aPlayField);
    void timerTick(void);
	void showEvent();
    void hideEvent();
	void SetMainView(CIceBloxxView* aView);
	 void keyPressEvent(QKeyEvent *event);
    void keyReleaseEvent(QKeyEvent *event);
    void mousePressEvent(QMouseEvent *event);
protected:
   void paintEvent(QPaintEvent *event);
    
//    void resizeEvent(QResizeEvent *event);
private:
    void drawIntro_1(void);
    void drawIntro_2(void);
    void drawIntro_3(void);
    void drawField(void);
    void drawGameOver(void);
	void drawHiScore();
    void makeField(void);
    void check_field(enum Types map[max_rows][max_cols],
	bool visible[max_rows][max_cols], int row, int col);
    bool isFieldOk(void);
    void clearField(void);
    void animateActors(void);
    void moveActors(void);
    void recreateFlames(void);
    void recreatePlayer(void);
    void killFlame(int actor);
    void killPlayer(void);
    void moveOrCrushBlock(int actor, enum Directions dir);
#ifdef CAN_TELEPORT
    void teleport(void);
#endif
    int detectCollision(int actor, int x, int y);
    int detectCollisionMovingBlock(int actor, int x, int y);
    int detectCollisionBlockOrWall(int actor, int x, int y);
    int detectCollisionFlame(int actor, int x, int y);
    int detectCollisionPlayer(int x, int y);
    int detectCollisionWall(int actor, int x, int y);
    bool hasReachedClickPosition(int x, int y);
    bool lineOfSight(int actor1, int actor2, enum Directions dir);
    void dump(const char *file, const char *function, int line);
	TInt m_Hiscores[10];
	TBuf<16> m_HiscoreNames[10];
	TBool CheckForHiscoreL();

	enum TSoundEffects
	{
		EPickUpCoinFx,
		ECrushIceFx,
		ELevelCompleteFx,
		EGameOverFx,
		EKillFireFx,
		EMoveBlockFx,
		ENumberFx
	};
	TInt m_SoundEffects[ENumberFx];
	void  LoadSoundsL();
	CSoundHandler* m_soundHandler;
};

#endif // __PLAYFIELD_HEADER__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -