AmmoManager.cpp
上传用户:hkb425
上传日期:2007-06-16
资源大小:34191k
文件大小:2k
- // AmmoManager.cpp: implementation of the CAmmoManager class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "AmmoManager.h"
- #include "texture.h"
- #include "math.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CAmmoManager::CAmmoManager()
- {
-
- }
- CAmmoManager::~CAmmoManager()
- {
- }
- bool CAmmoManager::InitAmmoManager()
- {
- CTexture cTexture;
- if(!cTexture.MakeAlphaTextureBind("texture/smoke.bmp", &texid))return false;
- return true;
- }
- void CAmmoManager::LaunchRocket(VERTEX startPos,float rotx,float roty )
- {
- NORMAL direction;
- direction.nx=-cosf(rotx*0.0174533f)*sinf(roty*0.0174533f);
- direction.ny=-sinf(rotx*0.0174533f);
- direction.nz=-cosf(rotx*0.0174533f)*cosf(roty*0.0174533f);
- LaunchRocket(startPos,rotx,roty ,direction);
- }
- void CAmmoManager::LaunchRocket(VERTEX startPos,float rotx,float roty ,NORMAL normal)
- {
- int index=0;
- bool bSuccess=false;
- while(index<MAXROCKET && (!bSuccess))
- {
- if(m_rocketList[index].m_life==0)
- {
- m_rocketList[index].InitRocket(startPos,rotx,roty,normal,texid);
- bSuccess=true;
- }
- index++;
- }
- }
- void CAmmoManager::UpdateAmmoManager()
- {
- for(int i=0;i<MAXROCKET;i++)
- {
- if(m_rocketList[i].m_life>0) //flying
- {
- m_rocketList[i].UpdateRocket();
- m_rocketList[i].DrawRocket();
- }
- }
- }
- void CAmmoManager::DrawAmmoManager()
- {
- m_rifle.DrawRifleShot();
- }
- //////////////////////////////////////////
- ////////////////////////////////////////
- /////////////////////////////////////////////
- void CAmmoManager::RifleFire(VERTEX startPos,float rotx,float roty )
- {
- NORMAL direction;
- direction.nx=-cosf(rotx*0.0174533f)*sinf(roty*0.0174533f);
- direction.ny=-sinf(rotx*0.0174533f);
- direction.nz=-cosf(rotx*0.0174533f)*cosf(roty*0.0174533f);
- m_rifle.LunchBullet(1,startPos,rotx,roty , direction);
- }