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

📄 cball.h

📁 一个3D的保龄球的源代码
💻 H
字号:
/*
* ============================================================================
*  Name     : CBall.h: 
*  Part of  : Game
*  Created  : 2004-09-27 by Wei XIA
*  Implementation notes:
*   interface for the CBall class.
*  Version  :
*  Copyright: Gameloft S.A.
*
* ============================================================================
*/
#if !defined AFX_BALL_H
#define AFX_BALL_H

//the default max value for each property
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "..\System\imath.h"
#include "def.h"
#include "Object.h"
#include "CPlayer.h"

const int BALL_VELOCITY_EXTENSION = 100; 

enum BALL_TYPE
{
	BALL_TYPE_ONE = 0,
	BALL_TYPE_TWO,
	BALL_TYPE_THREE,
	BALL_TYPE_FOUR,
	BALL_TYPE_FIVE,
	BALL_TYPE_SIX,
	BALL_TYOE_COUNT,
};


class CBall :public CObject
{
public:
	
	CBall();
	CBall(int ballType);
	~CBall();
	void initBall();
void computeRotationSpeed(int rotationPowerLevel);
	void	setBallType(int rotationPower);
	bool	isIntoBallOutSide();
	void	intoBallOutSide();
	bool	isIntoBallInvalid();
	
	////////////////////////////////////////////private functions
	
public:	
	void StepWithPlayer(CPlayer *player, Vector4s *hand, bool withHand);
	bool m_bInGutter;
	bool m_bIsThrown;
	void IsValid();
	void GoToNext();
	void SetBallVelocity(Vector4s desPos, Vector4s StaPos, int time);
	void SetRenderingProperty(int frame);
	void SetIsThrown(bool isThrown) {m_bIsThrown = isThrown;};
	
	

	//Properties of CBall
	int m_radius;
	int m_weight;
	int m_rotationSpeed;
	int power;
	int m_powerBar;
	

	
	
	//the current position when ball is moving
	/*  private int m_currentBallPositionX;
    private int m_currentBallPositionY;
    private int m_currentBallPositionZ;*/
	//int m_currentBallPosition[3];
	//the Velocity of ball
	int m_ballVelocityX;
	int m_ballVelocityY;
	//the velocity of ball in gutter
	int m_ballGutterVelocity;
	
	//acceleration
	/** ball acceleration on x coordinate on light oil area*/
	int m_ballLAccelerationX;
	/** ball acceleration on y coordinate on light oil area */
	int m_ballLAccelerationY;
	/** ball acceleration on x coordinate on unoil area */
	int m_ballUAccelerationX;
	/** ball acceleration on y coordinate on unoil area */
	int m_ballUAccelerationY;
	//state of ball
	Byte m_ballState;
	///** ball curve type: linear, saucer or curve */
	int m_ballCurveType;
	/** ball spin direction: clockwise or anti-clockwise */
	int m_ballRotationDirection;
	/** ball rolling degree */
	int m_ballRollingDegree;
	/** ball rolling degree */
	int m_ballRollingArray[3];	
	

	int dirRand;// the random direction 
	CTexture m_Texture;
	
	int GetTexid() { return m_texid;	};
	void SetTexid(CGraphics3D* p3d, int texid) { 
		m_texid = texid;
		m_Texture.m_w = p3d->m_pTextures[m_texid].m_w;
		m_Texture.m_h = p3d->m_pTextures[m_texid].m_h;
		m_Texture.m_mask = p3d->m_pTextures[m_texid].m_mask;
		m_Texture.m_shift = p3d->m_pTextures[m_texid].m_shift;
	}
	
	virtual void Render(CRender3D *pR3d)	{
		CGraphics3D *p3d = pR3d->GetG3d();
		if (m_bHide)
			return;
		UpdateWorldMat(); // Milo 10-27
		if (p3d->m_renderParam & RP_MIRROR)	{
			CMatrix44 mat;
			mat.m[8] = -COS_SIN_MUL;
			mat.PostMultiply(&m_matWorld);
			p3d->SetMatrix(0, &mat);
		}	else
			p3d->SetMatrix(0, &m_matWorld);
		p3d->SetTexture(&m_Texture);
		p3d->DrawBall();
	}

	int m_texid;
	
private:
	int m_PositionX;// the x position of the ball, which is 100 times of the real position
	int bFirstRun;

};



#endif

⌨️ 快捷键说明

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