📄 player.cpp.svn-base
字号:
#include "player.h"
#include "game_object.h"
#include "msgroute.h"
#include "fsm_player.h"
#include "custom_time.h"
#include "msg.h"
#include "util.h"
#include "../gamedata/gamedata.h"
#include "../ui/ui.h"
#include "math.h"
#include <windows.h>
float playerSpeed;
float rotSpeed;
Vertex runVector;
//----------------------------------------------------------------------------------
//对于player的初始化最好是放在loadMission里面做,单独拿出来是因为答辩之前来不及改了。
//这个文件里的东西都很简单,就不啰嗦了
//----------------------------------------------------------------------------------
void InitPlayer()
{
playerSpeed = 0.02f;
rotSpeed = 0.08f;
runVector.x = 0;
runVector.y = 0;
runVector.z = 0;
mouseX = CENTER_X;
mouseY = CENTER_Y;
SetCursorPos(CENTER_X, CENTER_Y);
for(int i=0;i<256;i++)
key[i]=false;
player.pos.x = 680;
player.pos.z = 320;
player.pos.y = map.getHeight(player.pos.x, player.pos.z);
player.model = new MDLModel();
player.model->Init("../Data/model/hgrunt.mdl");
//player.model->SetSequence("stand");
float min[3];
float max[3];
player.model->ExtractBbox(min,max);
player.lenX = (max[0]-min[0])*0.03;
player.lenY = (max[1]-min[1])*0.15;
player.lenZ = (max[2]-min[2])*0.03;
//player.pos.y = 200;
player.checked = false;
player.collide = false;
player.NeedChecked = false;
player.radius = sqrt(pow(player.lenX, 2) + pow(player.lenZ, 2) / 2);
//player.radius = 1.5f;
player.rotY = 0;
player.moveSpeed = playerSpeed;
player.health = 10000;
player.aggressivity = 50;
GOInitialize(&player, 0);
//FSMInitialize(player.unique_id, FSM_Player);
}
void UpdatePlayer()
{
GOUpdate(&player);
}
void MovePlayerFromTo(Vertex from, Vertex to)
{
extra_data ex;
ex.pos = from;
SendMsg(MSG_ScriptSetPosition, player.unique_id, player.unique_id, ex);
ex.pos = to;
SendMsg(MSG_ScriptSetDest, player.unique_id, player.unique_id, ex);
SetPlayerDirection(GetRotY(player.pos, player.dest));
}
void SetPlayerDirection(float roty)
{
extra_data ex;
ex.rotY = roty;
SendMsg(MSG_ScriptSetDirection, player.unique_id, player.unique_id, ex);
}
void CalcPlayerNewPos()
{
SendMsg(MSG_CalcNewPos, player.unique_id, player.unique_id);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -