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

📄 gameframe.h

📁 这是一个用BREW和VC++开发的暴力摩托游戏,与大家一同分享.
💻 H
字号:
//////////////////////////////////////////////////////////////////////
// File: GameFrame.h
// Author: Ying Zhang
// Decription: Game Framework containing game loop, game play etc
//////////////////////////////////////////////////////////////////////

#ifndef _GAME_FRAME
#define _GAME_FRAME

#include "AEEDisp.h"		// AEE Display Services
#include "AEEGraphics.h"    // AEE Graphics Services

#include "Ducati.h"
#include "Utility.h"
#include "Frontend.h"
#include "Data.h"
#include "KSCUtil.h"

class Ducati;
class Graphics;
class Frontend;
class Data;
class Random;

#define FRAMETIMEMS	100 //55

#define MAX_LEAN 0x29000
#define POWERSLIDE_TIME 40

#define ROAD_BITMAP_WIDTH 256
#define ROAD_BITMAP_HEIGHT 32
#define VISIBLE_ROAD_LENGTH_FRAC 4096
#define VISIBLE_ROAD_LENGTH (VISIBLE_ROAD_LENGTH_FRAC << 16)
#define FLAT_HILL_INCREMENT (VISIBLE_ROAD_LENGTH >> 5)
#define HILL_APPROACH_DIST 4096

#define NUM_DRAWTAB	(ROAD_BITMAP_HEIGHT * 2)

enum eGAMESTATE
{
	GS_FRONTEND,
	GS_RACING
};

class GameFrame 
{
friend class Frontend;
public:
	GameFrame(Ducati* pAppInterface, IShell* pIShell);
	~GameFrame();

	int		m_gameState;
	boolean	m_bRunning;
	int		pSlide;

	boolean Init();
	void	GameTick(int timerDelta);

	void	KeyPressed(uint16 wParam);
	void	KeyReleased(uint16 wParam);

	void	PauseGame(boolean bSuspendSnd);
	void	UnpauseGame();

	void	StartSound(bool load=false);
	void	StopSound(bool unload=false);
	void	GameLoop();
private:
	IShell*			m_pIShell;
	IDisplay*		m_pIDisplay;
	IGraphics*		m_pIGraphics;
	AEEDeviceInfo   m_DeviceInfo;

	Graphics*		m_pGraph;	// Named Graph to minimise confusion with m_pIGraphics.

	KSCUtil*		m_pKscUtil;

	Frontend*		m_pFrontend;
	Data*			m_pData;
	Random*         m_pRandom;

	int				m_canvasW;
	int				m_canvasH;
	
	long			m_raceStartTime;
	long			m_currentMillisecs;

	int				m_frameTime;
	long			m_frameStart;
	long			m_frameEnd;
	int				m_frameSkip;
	boolean			m_bRainning;
	long			m_nextRain;
	int				m_rainX[NUM_RAINDROPS];
	int				m_rainY[NUM_RAINDROPS];
	int				m_rainVel[NUM_RAINDROPS];

	int				m_isCliff;

	int				m_numberOfLaps;
	int				m_trackLength;
	int*			m_pTrackData;	//Points to array of track data

	int				m_bendIdx;
	int				m_bendPos;
	int				m_bendEndPos;
	int				m_bendLength;
	int				m_bendAngle;

	int				m_hillIdx;
	int				m_hillPos;
	int				m_hillLength;
	int				m_hillAngle;

	int				m_cliffY;

	short			m_tunnelIdx;
	int				m_tunnelZPos;
	int				m_tunnelLength;

	int				m_backdropXPos;
	int				m_backdropWidth;

	int				m_skyXPos;
	int				m_skyWidth;

	//Light and Dark segment of the road surface;
	uint32			m_roadColourL[NUM_TRACKS];
	uint32			m_roadColourD[NUM_TRACKS];

	uint32			m_SkyColour[NUM_TRACKS];
	uint32			m_TarmacColour[NUM_TRACKS];

	int				m_lean;
	int				m_drag;
	int				m_revs;
	int				m_topSpeed;

	boolean			m_bCrashing;
	long			m_crashTime;
	int				m_crashSpeed;
	int				m_crashX;
	int				m_crashY;

	int				m_partsWear[NUM_PARTS];
	int				m_maxSpeed;
	int				m_handling;
	int				m_acceleration;

	boolean			m_bDoingPowerSlide;
	int				m_powerSlideCount;
	long			m_powerSlideStart;
	boolean			m_bWobbledLastTime;

	long			m_lapStartTime;
	long			m_lastLapTime;
	long			m_bestLapTime;
	long			m_raceTime;
	boolean			m_bRace_over;

	Random*         m_pTreeRandom;
	int				m_firstTree;
	int				m_treeX[NUM_TREES];
	int				m_treeZ[NUM_TREES];

	char			m_sceneryTypes[NUM_SCENERY];
	int				m_sceneryX[NUM_SCENERY];
	int				m_sceneryZ[NUM_SCENERY];
	int				m_numSceneryObjects;
	int				m_lastSceneryItem;

	short			m_screenCoords[NUM_COORD];
	int				m_distTab[NUM_DIST];
	int				m_numBikes;

	int				m_xPos[NUM_BIKES];
	int				m_zPos[NUM_BIKES];
	int				m_speed[NUM_BIKES];
	int				m_onBend[NUM_BIKES];
	int				m_score[NUM_BIKES];
	int				m_racePos[NUM_BIKES];
	int				m_lap[NUM_BIKES];
	int				m_gear[NUM_BIKES];
	int				m_desiredGear[NUM_BIKES];
	int				m_character[NUM_BIKES];
	int				m_speedRatio[NUM_BIKES];
	int				m_gearSpeeds[NUM_BIKES][NUM_GEAR];
	int				m_lastFace[NUM_BIKES];

	int				m_drawOrder[NUM_BIKES];
	int				m_drawPos[NUM_BIKES];

	int				m_padData;
	int				m_lastPad;
	int				m_debouncePad;

	long			m_pausedTime;
	boolean			m_bPaused;

	int				m_leftCanyonIdx;
	int				m_rightCanyonIdx;
	int				m_xDrawTab[NUM_DRAWTAB];
	int				m_zDrawTab[NUM_DRAWTAB];
	int				m_drawIdx;

	int**			m_pTrackTable;
	int**			m_pTrackSceneryTable;
	short**			m_pTreeVtxTable;
	short**			m_pTreePolyTable;

	AEEImageInfo	m_imageInfo;

	// Game Loop/ Timer/ Ticker
	static void GameLoop(void *user);


	void		Draw();
	void		UpdateScreen();

	void		InitRace();
	void		InitialiseGame();
	void		InitRoad(int trackNum);
	int*		InitTrack(int trackNum);
	void		InitRain();
	void		InitPanel();

	void		ResetBends();
	int			GetCurrentBend(int pos);
	void		GetNextBend();
	void		GetNextHill();
	void		GetNextTunnel();
	void		InitTunnels();

	void		InitPlayer();
	void		ControlPlayer();
	void		Crash(int pos);
	void		Collision();
	void		LoseSpeed();

	void		GenCPUCharacters(int player);
	void		InitBikes();
	void		AddBike(int x);
	void		InitScenery();

	void		GenerateScenery(int* pScenery);
	void		AddArrows(int z, short xPos, char type);
	void		AddPosts(int z, int end, short xPos, char type);
	void		AddTelegraphPoles(int z, int end, short xPos);
	void		AddFence(int z, int end, short xPos);
	void		AddTree(int idx, int z);

	void		CalcGearSpeeds(int bike);
	void		RecalcTopSpeed();

	void		UpdatePad();
	void		ClearPad();

	void		SortDrawOrder();
	void		SortScenery();

	void		CalcRacePosition(int bike);
	void		FillRoadTab(int roadZ, int x);

	void		DrawLapNum();
	void		DrawCanyonRoad();
	int			DrawCanyonScenery(int canyonIdx, int* pTab, int zStop);
	void		DrawBackdrop(int yPos);
	void		DrawSky();
	void		DrawCliffsideLeft();
	void		DrawCliffsideRight();
	void		DrawRoad();
	void		DrawScenery();
	void		DrawTree(int tree);
	void		DrawModel(short* pModel, int numElems);
	void		DrawBikes();
	void		DrawPlayer();
	void		DrawBike(int x,int y,int frame,short* pOffset,IImage* im);
	void		DrawRain();
	void		DrawPanel();
	void		DrawPanelTime(int x,int time);
	void		DrawFace(int face,int x,int y);
	void		DrawStartLights(long time);

	void		CalcScreenCoords(short* pModelCoords, int numCoords, int x, int z);
	JString		GetTimeString(long time);

	void		Ai();
	void		GetDrag(int outCurve);
	void		ScrollBackdrop(int amount);

	int			Sin(int angle);
	int			Cos(int angle);
	
};

#endif // #ifndef _GAME_FRAME

⌨️ 快捷键说明

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