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

📄 game_object.h.svn-base

📁 自己做的小游戏
💻 SVN-BASE
字号:
/* Copyright (C) Steve Rabin, 2000. 
* All rights reserved worldwide.
*
* This software is provided "as is" without express or implied
* warranties. You may freely copy and compile this source into
* applications you distribute provided that the copyright text
* below is included in the resulting source code, for example:
* "Portions Copyright (C) Steve Rabin, 2000"
*/
//////////////////////////////////////////////////////////////
//
// Filename: game_object.h
//
// Author: Steve Rabin
// E-mail: stevera@noa.nintendo.com
// From the book "Game Programming Gems"
// From the article "Designing a General Robust AI Engine"
//
// Brief Disclaimer:
// This code is free to use for commercial use and is in the
// public domain. You may distribute, copy, modify, or use as
// is as long as this information is present. This code makes
// no guarantees written or implied and is provided solely as
// an example. Have a nice day!
//
// Purpose:
// This file contains the code to initialize and update
// game objects.
//
//////////////////////////////////////////////////////////////

#ifndef _GAME_OBJECT_H
#define _GAME_OBJECT_H

#include "fsm.h"
#include "../gamedata/mdlmodel.h"


//用于状态机
typedef struct GameObject_Str
{
	unsigned int unique_id;		//This game object is referenced by a unique id

	//State machine info
	FSM_Type state_machine_id;	//the state machine that this object running
	unsigned int state;			//the current state of the state machine
	unsigned int next_state;		//the next state when a state change was requested
	bool force_state_change;		//whether a state change has been requested

	//Put other game object info in here
	//下面这些东西实际上对于每种游戏对象都不一样,由于Chaos目前只有一种游戏角色,所以硬编码到这里
	//这样子的结构是不好的,扩展性不好,应该在这部分只放一个指针,指向每种角色特定的信息
	char szName[256];		//目前没用到。每个怪物的名字
	bool bMarkedForDeletion;		//是否需要删除
	
	void *ex;		//目前没用到


	int maxHealth;		//目前没用到
	int health;		//当前生命值
	int aggressivity;		//攻击力
	int attackDist;		//攻击范围
	int eyeDist;		//看的范围
	int earDist;		//听的范围
	float moveSpeed;	//移动速度
	float height;		//身高
	float oneStepLen;	//一步的距离。目前没用到。

	MDLModel *model;		//对应的模型
	float lenX,lenY,lenZ;		//模型的长宽高,用于碰撞检测
	Vertex oldPos, newPos;		//这一帧的开始时,它的旧位置和新位置。新位置是这一帧它将要去的地方,但不一定去得了,因为要做碰撞检测这两个变量就是干这个用的。
	float radius;		//模型的半径。用于碰撞检测

	//这三个变量起初的目的是为了debug,不过后来它们自己引起了一些bug。
	bool NeedChecked;		//是否需要进行碰撞检测
	bool checked;			//是否已经进行过碰撞检测
	bool collide;			//是否碰撞

	Vertex pos;		//当前位置
	float rotY;		//当前的方向,即它的前方与xz的z轴正方向的夹角,顺时针为正

	Animation ani[3];		//目前没用到。存储每种动画的信息。

	Vertex dest;		//在播放动画的时候用到。它将要去的目的地。
} GameObject;


//这个忘删了,Chaos中没用到。
struct GameObjType
{
	GameObject obj;
	char name[10];
	char modelPath[50];
};



void	GOInitialize( GameObject* go, unsigned int unique_id );
void	GOUpdate( GameObject* go );
void	GODraw( GameObject* go );



#endif

⌨️ 快捷键说明

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