コード例 #1
0
ファイル: ship.cpp プロジェクト: markettwp/Epiar
/**\brief Update function on every frame.
 */
void Ship::Update( lua_State *L ) {
	Sprite::Update( L ); // update momentum and other generic sprite attributes
	
	if( status.isAccelerating == false 
		&& status.isRotatingLeft == false
		&& status.isRotatingRight == false) {
		flareAnimation->Reset();
	}
	flareAnimation->Update();
	Coordinate momentum	= GetMomentum();
	momentum.EnforceMagnitude( shipStats.GetMaxSpeed()*engineBooster );
	// Show the hits taken as part of the radar color
	if(IsDisabled()) SetRadarColor( GREY );
	else SetRadarColor( RED * GetHullIntegrityPct() );
	
	// Ship has taken as much damage as possible...
	// It Explodes!
	if( status.hullDamage >=  (float)shipStats.GetHullStrength() ) {
		SpriteManager *sprites = Simulation_Lua::GetSimulation(L)->GetSpriteManager();
		Camera* camera = Simulation_Lua::GetSimulation(L)->GetCamera();

		// Play explode sound
		if(OPTION(int, "options/sound/explosions")) {
			Sound *explodesnd = Sound::Get("Resources/Audio/Effects/18384__inferno__largex.wav.ogg");
			explodesnd->Play( GetWorldPosition() - camera->GetFocusCoordinate());
		}

		// Create Explosion
		sprites->Add( new Effect( GetWorldPosition(), "Resources/Animations/explosion1.ani", 0) );

		// Remove this Sprite from the SpriteManager
		sprites->Delete( (Sprite*)this );
	}
コード例 #2
0
ファイル: projectile.cpp プロジェクト: eoi/Epiar
/**\brief Constructor
 */
Projectile::Projectile(float damageBooster, float angleToFire, Coordinate worldPosition, Coordinate firedMomentum, Weapon* _weapon)
{
	damageBoost=damageBooster;
	// All Projectiles get these
	ownerID = 0;
	targetID = 0;
	start = Timer::GetTicks();
	SetRadarColor (Color(0x55,0x55,0x55));

	// These are based off of the Ship firing this projectile
	SetWorldPosition( worldPosition );
	SetAngle(angleToFire);

	// These are based off of the Weapon
	weapon = _weapon;
	secondsOfLife = weapon->GetLifetime();
	SetImage(weapon->GetImage());

	Trig *trig = Trig::Instance();
	Coordinate momentum = GetMomentum();
	float angle = static_cast<float>(trig->DegToRad( angleToFire ));

	momentum = firedMomentum +
	           Coordinate( trig->GetCos( angle ) * weapon->GetVelocity(),
	                      -trig->GetSin( angle ) * weapon->GetVelocity() );
	
	SetMomentum( momentum );
}
コード例 #3
0
ファイル: ship.cpp プロジェクト: markettwp/Epiar
/**\brief Ship constructor that initializes default values.
 */
Ship::Ship()
{
	model = NULL;
	engine = NULL;
	flareAnimation = NULL;
	
	/* Initalize ship's condition */
	damageBooster=1.0;
	engineBooster=1.0;
	shieldBooster=1.0;
	status.hullDamage = 0;
	status.shieldDamage = 0;
	status.lastWeaponChangeAt = 0;

	memset(status.lastFiredAt, 0, sizeof(status.lastFiredAt));

	status.selectedWeapon = 0;
	status.cargoSpaceUsed = 0;
	status.isAccelerating = false;
	status.isRotatingLeft = false;
	status.isRotatingRight = false;
	status.isDisabled = false;
	for(int a=0;a<max_ammo;a++){
		ammo[a]=0;
	}

	shipStats = Outfit();

	SetRadarColor( RED );
	SetAngle( float( rand() %360 ) );
}
コード例 #4
0
ファイル: planets.cpp プロジェクト: Maka7879/Epiar
/**\brief Constructor using a full Full Description
 */
Planet::Planet( string _name, float _x, float _y, Image* _image, Alliance* _alliance, bool _landable, int _traffic, int _militiaSize, int _sphereOfInfluence, list<Technology*> _technologies):
	alliance(_alliance),
	landable(_landable),
	traffic(_traffic),
	militiaSize(_militiaSize),
	sphereOfInfluence(_sphereOfInfluence),
	technologies(_technologies)
{
	// Check the inputs
	assert(_image);
	assert(_alliance);

	Coordinate pos;
	pos.SetX(_x);
	pos.SetY(_y);
	SetWorldPosition( pos );
	SetName(_name);
	SetImage(_image);
	Image::Store(name,GetImage());
	SetRadarColor(Color::Get(48, 160, 255));
}
コード例 #5
0
ファイル: planets.cpp プロジェクト: Maka7879/Epiar
/**\brief Blank Constructor
 */
Planet::Planet(){
	SetRadarColor(Color::Get(48, 160, 255));
}