The entrance (WinMain) to the application is in NetWars.cpp. It is currently utilizing DirectX, D3DX, XInput (360 controller), Box2D and eventually Enet for networking.
Last Updated 5/30/08
//-----------------------------------------------------------------------------
// SpaceShip implementation.
//-----------------------------------------------------------------------------
#include "NetWars.h"
//-----------------------------------------------------------------------------
// The SpaceShip class constructor.
//-----------------------------------------------------------------------------
SpaceShip::SpaceShip( float x, float y )
{
m_objectType = "Ship";
simplevertex vertices[] =
{
{ -7.0f, -5.0f, 0.0f, },
{ -2.0f, 0.0f, 0.0f,},
{ 0.0f, 9.0f, 0.0f, },
{ 2.0f, 0.0f, 0.0f, },
{ 7.0f, -5.0f, 0.0f, },
{ 0.0f, -7.0f, 0.0f, },
{ -7.0f, -5.0f, 0.0f, },
};
Initialize( x, y );
int numberOfVerticies = (int) sizeof( vertices ) / sizeof( simplevertex );
CreateVertexBuffer( vertices, numberOfVerticies );
m_Shield = new Shield( x, y, 10.0f );
g_Engine->AddSceneObject( m_Shield );
m_shieldDetatched = false;
m_angle = 0.0f;
//m_shieldRadius = 10.0f;
}
//-----------------------------------------------------------------------------
// The SpaceShip rotate method
//-----------------------------------------------------------------------------
void SpaceShip::Rotate( float angle )
{
m_angle = angle;
SceneObject::Rotate( angle );
m_Shield->Rotate( angle );
}
//-----------------------------------------------------------------------------
// The SpaceShip move method
//-----------------------------------------------------------------------------
void SpaceShip::Move( float x, float y )
{
SceneObject::Move( x, y );
if( !m_shieldDetatched )
{
m_Shield->Move( x, y );
}
}
//-----------------------------------------------------------------------------
// The SpaceShip Method that creates the Physical body.
//-----------------------------------------------------------------------------
void SpaceShip::SetUpPhysics( float x, float y )
{
// Set up the b2D Body Def:
b2BodyDef bodyDef;
bodyDef.position.Set(x, y);
bodyDef.allowSleep = false;
// Set up the b2D Body Def:
b2CircleDef circleDef;
circleDef.radius = 10.0f;
circleDef.density = 1.0f;
circleDef.friction = 0.0f;
circleDef.restitution = 0.1f;
g_Engine->GetB2D()->AddBody( &m_Body, &bodyDef, &circleDef );
m_physicalBody = true;
}
//-----------------------------------------------------------------------------
// The SpaceShip Method that Fires the shield.
//-----------------------------------------------------------------------------
void SpaceShip::FireShield( )
{
if( m_shieldDetatched == false )
{
m_shieldDetatched = true;
m_Shield->Fire( GetX() + 15.0f * cos( m_angle + 3.14 ), GetY() + 15.0f * sin( m_angle + 3.14 ), (m_angle + 3.14) );
}
}
//-----------------------------------------------------------------------------
// The SpaceShip Method that Attaches the shield.
//-----------------------------------------------------------------------------
void SpaceShip::AttachShield( )
{
if( m_shieldDetatched )
{
m_shieldDetatched = false;
m_Shield->Attach();
}
}