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

📄 player.h

📁 “恐怖之战”游戏源码
💻 H
字号:
#ifndef __PLAYER_H
#define __PLAYER_H

#include <typeinfo.h>

#include "audiosystem.h"
#include "sod.h"
#include "ogro.h"
#include "rocket.h"
#include "camera.h"
#include "object.h"
#include "terrain.h"

class CPlayer : public CObject
{
private:
	CCamera *camera;
	CTerrain *terrain;
	CAudioSystem *audioSys;
	CAudio *rocketSound;

protected:
	void OnCollision(CObject *collisionObject)
	{
		if (typeid(*collisionObject) == typeid(CTerrain))
		{
			position.y = ((CTerrain*)collisionObject)->GetHeight(position.x, position.z) + size;
		}
		else if (typeid(*collisionObject) == typeid(COgroEnemy))
		{
			if (camera)
			{
				if (camera->velocity.z > 0.0)
					camera->velocity = CVector(0.0, 0.0, 0.0);
			}
		}
		else if (typeid(*collisionObject) == typeid(CSodEnemy))
		{
			if (camera)
			{
				if (camera->velocity.z > 0.0)
					camera->velocity = CVector(0.0, 0.0, 0.0);
			}
		}
		else if (typeid(*collisionObject) == typeid(CPlayer))
		{
		}
	}

	void OnPrepare()
	{
		if (camera)
		{
			position = camera->position;	// 游戏者的位置与摄像机位置一致
			direction = camera->yaw;
			pitch = camera->pitch;
		}
	}

public:
	float direction;	// 游戏者面对的方向
	float pitch;		// 游戏者视线的倾斜度

	CPlayer() { size = 7.0f; camera = NULL; terrain = NULL; audioSys = NULL; rocketSound = NULL; }
	~CPlayer() {}

	void SetCamera(CCamera *c) { camera = c; }
	void DetachCamera() { camera = NULL; }
	void SetTerrain(CTerrain *t) { terrain = t; }
	void FireWeapon();
	void SetAudioSystem(CAudioSystem *aSys) { audioSys = aSys; }
};

#endif

⌨️ 快捷键说明

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