📄 weapon.cpp
字号:
// (C) Copyright 1996 by Anthony J. Carin. All Rights Reserved.
#include <stdafx.h>
#include <weapon.h>
#include "levels.h"
#include <mmsystem.h>
weapon::weapon(CString& weapondat) : handheld()
{
hitfloor = FALSE;
throwing = FALSE;
pickingup = FALSE;
delete m_body;
CString tmpstr;
if (weapondat.CompareNoCase((CString)"SHIELD.DAT") == 0)
m_hhtype = SHIELD;
else if (weapondat.CompareNoCase((CString)"SWORD.DAT") == 0)
m_hhtype = SWORD;
else
m_hhtype = KNIFE;
tmpstr = picklist((float)random(100)/100.0f, getpath(weapondat));
if (!tmpstr.IsEmpty())
{
m_body = new image((LPCTSTR) getpath(tmpstr));
int color = random(100) + 70;
m_body->setcolor(RGB(color,color,color+10));
}
else
m_body = 0;
}
void weapon::draw()
{
handheld::draw();
if (Next || Prev)
{
if (hitfloor)
throwing = FALSE;
if (throwing)
{
coordinate tmp = location();
coordinate tmp2 = tmp;
tmp.setx(tmp.x() + tcsin(throwdir, throwspeed));
tmp.setz(tmp.z() + tccos(throwdir, throwspeed));
tmp2.stepto(tmp, throwspeed);
setto(tmp2);
setzposition(flipdir);
flipdir = flipdir - (direction) TC_PI_4;
m_view.setxdir(m_view.x()+TC_PI_2);
}
}
}
void weapon::Throw(direction& dir, float speed)
{
throwing = TRUE;
throwdir = dir;
flipdir = dir;
throwspeed = speed;
}
void handheld::draw()
{
baseobject::draw();
if (Next || Prev)
{
m_prevview = m_view;
settledown(0.0f);
if (m_prevview.y() == m_view.y() && !hitfloor)
{
hitfloor = TRUE;
PlaySound(getpath((CString)"hitfloor.wav"), NULL, SND_ASYNC);
}
if (Game->LevelPtr()->GuyLocation().distanceto(location()) < .5f && hitfloor)
{
if (!pickingup)
{
pickingup = TRUE;
Game->LevelPtr()->usercontrol->pickup();
}
}
else
pickingup = FALSE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -