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

📄 cgame.h

📁 Symbian平台下的一个3D赛车游戏源码
💻 H
字号:
   /*
============================================================================
    * Name : CGame.h
    * Part of : Example3D
    * Description : Definition of CGame
    * Copyright (c) 2005 Nokia Corporation
============================================================================
    */

#ifndef __CGAME_H__
#define __CGAME_H__


// INCLUDES
#include <e32base.h>
#include "MGame.h"
#include "3dtypes.h"

#ifdef GLES

#include "GLES/egl.h"
#include "GLES/gl.h"

#endif


   
// FORWARD DECLARATIONS
class C3DBase;
class C3DRenderer;
class CPolygonObject;
class CFpsCounter;

// ENUMERATIONS

enum TCameraMode
	{
	ECameraBehind,	// camera follows behind car
	ECameraInCar,	// in-car camera
	ECameraSouth,	// camera follows car and looks at car from south
	ECameraTV1,		// TV-cameras around the field
	ECameraTV2,
	ECameraTV3,
	ECameraTV4,
	ECameraNone		// Null camera
	};


// CLASS DECLARATION

/**
*  CGame implemets MGame class
*  MGame classes are used by CEngine
*  Which calls Draw and Move functions
*/

class CGame
	: public CBase
	, public MGame
	{
	public:
		
		/// Two-phased constructor
		/// @param aDisplayMode display's color mode
		/// @param aScreen bitmap to draw to
		static CGame* NewL( TDisplayMode aDisplayMode );

		/// Destructor
		~CGame();

	private:
		
		/// Second-phase constructor
		/// @param aScreen bitmap to draw to
		void ConstructL();

		/// Default constructor
		CGame( TDisplayMode aDisplayMode );

	public: // MGame
		
		/// Called from CEngine
		/// @param aScreen bitmap to draw to
		void Draw( const TBitmap& aScreen );

		/// Called from CEngine
		/// @param aKey key table to read key press states
		/// for example if( aKey[ '1' ] ) Pause();
		void Move( TUint8* aKey );
		
		/// Helper function to get polygon count
		TInt PolygonCount();

		/// Gets commands from engine
		/// Engine gets these commands from application framework
		/// @param aCommand command index
		virtual void Command( TInt aCommand );

	private: // New methods:

		/// creates a wheel 3D-object with given parameters
		/// with more points the wheel is more like a circle
		/// @param aRadius wheel radius
		/// @param aWidth wheel width
		/// @param aNumPoints number of points used on wheel surface
		CPolygonObject*	CreateWheel( TInt aRadius, TInt aWidth, TInt aNumPoints );

		/// creates a 3D-object from given data
		/// @param aVertexData pointer to vertex data
		/// @param aFaceData pointer to face data
		/// @param aNumVertices number of vertices in vertex data
		/// @param aNumFaces number of faces in face data
		/// @param aTexOffset offset added to texture coordinates
		/// @param aTexMul original texture coordinates are multiplied with this
		CPolygonObject*	CreateObject( const TInt* aVertexData, const TInt* aFaceData,
									  TInt aNumVertices, TInt aNumFaces,
									  const TPoint& aTexOffset, TInt aTexMul );



		/// Draws text with polygons to polygon object
		/// destroys all previous data from polygon object
		/// supports newline ( '\n' )
		/// @param aObject 3D-object to draw to
		/// @param aStr, text to draw to object
		void DrawText( CPolygonObject* aObject, const TDesC8& aStr );


	private: // data

		TDisplayMode	iDisplayMode;	// color mode to use
		TBitmap			iScreen;		// screen bitmap

		TBitmap			iTexture;		// textures for car and road
		TBitmap			iTexture2;		// textures for house
		TBitmap			iTextureFont;	// texture for fonts

#ifdef GLES

		GLuint			iGlTexture;		// texture handles for OpenGL
		GLuint			iGlTexture2;
		GLuint			iGlTextureFont;
#endif

		C3DBase*		i3DBase;		// base for all 3D
		C3DRenderer*	iRender;		// 3D-renderer

		CPolygonObject*	i3dHouse;		// house building
		CPolygonObject*	i3dRoad;		// one tile of road
		CPolygonObject*	i3dGrass;		// one tile of grass
		CPolygonObject* i3dCar;			// the car
		CPolygonObject* i3dFrontWheel;	// one piece of front wheels
		CPolygonObject* i3dRearWheel;	// one piece of rear wheels
		CPolygonObject* i3dText;		// text table for statistics
		
		TInt	iCarAngle;				// car position and movemet parameters
		TInt	iCarAngleSpeed;
		TInt	iCarSpeed;
		TInt	iCarPos;
		TVertex iCarPosition;
		TVertex iCarPositionAdd;
		TInt	iCarTilt;
		
		TInt iSpeed;
		TInt iAngleSpeed;
		
		TInt	iSteerAngle;
		TInt	iThrottle;
		
		TInt iCameraMode;				// camera mode

		CFpsCounter* iFps;				// current speed Frames / Second
	};

#endif

⌨️ 快捷键说明

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