Show Shotgun.cpp syntax highlighted
#include "StdAfx.h"
#include "Shotgun.h"
#include <math.h>
#include "EntityFactory.h"
const float PI = 3.14159265358979323846f;
#define random() ((rand () & 0x7fff) / ((float)0x7fff))
#define crandom() (2.0f * (random() - 0.5f))
Shotgun::Shotgun(void) : IWeapon()
{
}
Shotgun::~Shotgun(void)
{
IWeapon::~IWeapon();
}
/** Fire this weapon */
void Shotgun::Fire()
{
IWeapon::Fire();
if ( IsFiring() )
{
SpreadBullets( m_owner->m_forward );
}
}
/** Randomize bullets */
void Shotgun::SpreadBullets(Vector2f &forward )
{
int amount = m_attributes.GetInt("bullets/sec");
int spread = m_attributes.GetInt("spread");
//EntityFactory entFact;
//for ( int i = 0; i < amount; ++i )
//{
// float r = random() * PI * 2.0f;
// float u = sin(r) * crandom() * spread * 16.0f;
// r = cos(r) * crandom() * spread * 16.0f;
// IBullet* b = entFact.CreateEntity<IBullet>( "" );
//
//
//}
//Vector2f end, dir, delta;
////Vector2f forward;
//end = (forward * 8102.0f * 16.0f) + m_world;
//// end = (right * r) + end;
//dir = m_world - end;
//dir.Normalize();
//float scale = 555.0f + crandom() * 1800.0f;
//delta = m_world * scale;
}
/** Reload this weapon */
void Shotgun::Reload()
{
}
/** Collide with this weapon */
bool Shotgun::CollideWith( IEntity *ent )
{
return false;
}
See more files for this project here