WEAPON.CPP
资源名称:tc3d.zip [点击查看]
上传用户:abcdshs
上传日期:2007-01-07
资源大小:1858k
文件大小:2k
源码类别:
游戏
开发平台:
Visual C++
- // (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;
- }
- }