Code Search for Developers
 
 
  

Shotgun.cpp from palisma2d at Krugle


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

palisma2d

The University of Wisconsin-Parkside Developers Union first product. More info to come. Code name Palisma.

Project homepage: http://code.google.com/p/palisma2d/
Programming language(s): C,C++
License: gpl2

  DialogModel.cpp
  DialogModel.h
  DialogState.cpp
  DialogState.h
  Enemy.cpp
  Enemy.h
  EntityController.cpp
  EntityController.h
  EntityEvents.cpp
  EntityEvents.h
  EntityFactory.cpp
  EntityFactory.h
  EntityManager.cpp
  EntityManager.h
  EntityStates.cpp
  EntityStates.h
  Event.h
  HUD.cpp
  HUD.h
  IEntity.cpp
  IEntity.h
  IWeapon.cpp
  IWeapon.h
  InGameState.cpp
  InGameState.h
  Inventory.cpp
  Inventory.h
  MissionHolder.cpp
  MissionHolder.h
  Player.cpp
  Player.h
  PlayerConfig.cpp
  PlayerConfig.h
  PlayerController.cpp
  PlayerController.h
  QuestImporter.cpp
  QuestImporter.h
  ReadMe.txt
  Scene.cpp
  Scene.h
  Shotgun.cpp
  Shotgun.h
  State.h
  StateFactory.cpp
  StateFactory.h
  StateMachine.cpp
  StateMachine.h
  Tile.cpp
  Tile.h
  Weather.cpp
  Weather.h
  stdafx.cpp
  stdafx.h