Initial spaceship
This commit is contained in:
@@ -2,16 +2,23 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
using SynthySound;
|
||||
|
||||
namespace EvilSatellites.Objects
|
||||
{
|
||||
public class Player : AbstractGameObject
|
||||
{
|
||||
private Vector3 _PrevPos;
|
||||
private Vector3 MaxSpeed = new Vector3(1, 1, 1);
|
||||
private Vector3 Deceleration = new Vector3(0.005f, 0.005f, 0.005f);
|
||||
private ISoundEffect sfxEngine;
|
||||
private ISoundEffect sfxWhine;
|
||||
public Player(IScreen screen): base(screen)
|
||||
{
|
||||
Type = ObjectType.Player;
|
||||
Position = new Vector3(10, 0, 0);
|
||||
Dimensions = new Vector3(5, 5, 5);
|
||||
Movement = new Vector3(0, 0, 0);
|
||||
Rotation = Matrix.Identity;
|
||||
Orientation = Rotation.Forward;
|
||||
Activate();
|
||||
@@ -19,6 +26,12 @@ namespace EvilSatellites.Objects
|
||||
|
||||
override public void Activate()
|
||||
{
|
||||
sfxEngine = Screen.Manager.Sound.Load(@"sfx/engine/int/engineThrust.wav", false);
|
||||
sfxWhine = Screen.Manager.Sound.Load(@"sfx/engine/int/engineWhine.wav", false);
|
||||
sfxEngine.Loop = true;
|
||||
sfxWhine.Loop = true;
|
||||
sfxEngine.Play();
|
||||
sfxWhine.Play();
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -30,6 +43,45 @@ namespace EvilSatellites.Objects
|
||||
}
|
||||
override public void Update(GameTime gameTime)
|
||||
{
|
||||
Move(Movement);
|
||||
sfxEngine.Pitch = 0.5 + (Movement.Length() / MaxSpeed.Length()) * 4;
|
||||
sfxWhine.Pitch = 0.5 + (Movement.Length() / MaxSpeed.Length()) * 1;
|
||||
sfxWhine.Volume = MathF.Pow(Movement.Length() / MaxSpeed.Length(), 2f);
|
||||
if (Movement.Length() != 0)
|
||||
{
|
||||
if (Movement.X > 0)
|
||||
{
|
||||
Movement.X -= Deceleration.X;
|
||||
} else
|
||||
{
|
||||
Movement.X += Deceleration.X;
|
||||
}
|
||||
if (Movement.Y > 0)
|
||||
{
|
||||
Movement.Y -= Deceleration.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
Movement.Y += Deceleration.Y;
|
||||
}
|
||||
if (Movement.Z > 0)
|
||||
{
|
||||
Movement.Z -= Deceleration.Z;
|
||||
}
|
||||
else
|
||||
{
|
||||
Movement.Z += Deceleration.Z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Accelerate()
|
||||
{
|
||||
Vector3 acc = new Vector3(0f, 0f, -0.035f);
|
||||
if (Math.Abs(Movement.X) < MaxSpeed.X && Math.Abs(Movement.Y) < MaxSpeed.Y && Math.Abs(Movement.Z) < MaxSpeed.Z)
|
||||
{
|
||||
Movement += acc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user