📄 bulletex.cpp
字号:
// BulletEx.cpp: implementation of the CBulletEx class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "BulletEx.h"
#include "AnimFrame.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBulletEx::CBulletEx()
{
}
CBulletEx::~CBulletEx()
{
}
//////////////////////////////////////////////////////////////////////////
// CPlasmaBullet
//////////////////////////////////////////////////////////////////////////
CPlasmaBullet::CPlasmaBullet()
{
m_vPos = D3DXVECTOR3(0,0,0);
m_vVelocity = D3DXVECTOR3(0,0,0);
}
CPlasmaBullet::CPlasmaBullet( D3DXVECTOR3 vPos, D3DXVECTOR3 vVelocity )
{
m_vPos = vPos;
m_vVelocity = vVelocity;
}
CPlasmaBullet::~CPlasmaBullet()
{
}
//////////////////////////////////////////////////////////////////////////
// CPlasmaBulletArray
//////////////////////////////////////////////////////////////////////////
/*
// maximum of 20 plasma bullets at once
const int CPlasmaBulletArray::NUMBULLETS = 100;
CPlasmaBulletArray::CPlasmaBulletArray()
{
m_pBullets = NULL;
m_pAnim = NULL;
}
CPlasmaBulletArray::~CPlasmaBulletArray()
{
}
HRESULT CPlasmaBulletArray::RestoreDeviceObjects()
{
m_pBullets = new CRecyclingArrayDyn<CPlasmaBullet>(NUMBULLETS);
m_pAnim = new CAnimSequence;
m_pAnim->Create();
m_pAnim->AddFrame(".\\data\\Game\\Effect\\PlasmaBullet.dds", 20.0f);
return S_OK;
}
HRESULT CPlasmaBulletArray::InvalidateDeviceObjects()
{
SAFE_DELETE(m_pBullets);
// SAFE_RELEASE(m_pVB);
SAFE_DELETE(m_pAnim);
return(S_OK);
}
void CPlasmaBulletArray::AddBullet(D3DXVECTOR3 vPos, D3DXVECTOR3 vVelocity)
{
CPlasmaBullet *newbullet = m_pBullets->New();
newbullet->Pos() = vPos;
newbullet->Velocity() = vVelocity;
newbullet->m_Sprite->SetAnim(m_pAnim);
newbullet->m_Sprite->Timer().Begin();
newbullet->m_Sprite->SetSize(RandomNumber(5.0f, 10.0f));
}
void CPlasmaBulletArray::UpdateAll(float fElapsedTime)
{
for (int q=0; q < NUMBULLETS; q++) {
if (m_pBullets->IsAlive(q)) {
CPlasmaBullet &bullet = m_pBullets->GetAt(q);
bullet.Pos() += bullet.Velocity()*fElapsedTime;
if (bullet.m_Sprite->Timer().IsRunning() &&
bullet.m_Sprite->Timer().GetTime() > 5.0f) {
m_pBullets->Delete(q);
}
}
}
}
void CPlasmaBulletArray::RenderAll()
{
g_pApp->GetD3dDevice()->SetRenderState(D3DRS_LIGHTING, FALSE );
g_pApp->GetD3dDevice()->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE );
g_pApp->GetD3dDevice()->SetRenderState(D3DRS_ZENABLE, FALSE);
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE);
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
g_pApp->GetD3dDevice()->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
g_pApp->GetD3dDevice()->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
g_pApp->GetD3dDevice()->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
g_pApp->GetD3dDevice()->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
g_pApp->GetD3dDevice()->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
// render all the bullets via one call to DrawPrimitive
for (int q=0; q < NUMBULLETS; q++) {
if (m_pBullets->IsAlive(q)) {
CPlasmaBullet &bullet = m_pBullets->GetAt(q);
bullet.m_Sprite->Pos() = bullet.Pos();
bullet.m_Sprite->Render( g_pCamera->GetViewMatrix() );
}
}
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -