Initial spaceship
This commit is contained in:
@@ -14,6 +14,19 @@ namespace EvilSatellites.Objects
|
||||
get => _Position;
|
||||
set => _Position = value;
|
||||
}
|
||||
private Vector3 _Dimensions;
|
||||
public Vector3 Dimensions
|
||||
{
|
||||
get => _Dimensions;
|
||||
set => _Dimensions = value;
|
||||
}
|
||||
public Vector3 Movement;
|
||||
// public Vector3 Movement
|
||||
// {
|
||||
// get => _Movement;
|
||||
// set => _Movement = value;
|
||||
// }
|
||||
|
||||
private Vector3 _Orientation;
|
||||
public Vector3 Orientation
|
||||
{
|
||||
|
||||
@@ -10,7 +10,9 @@ namespace EvilSatellites.Objects
|
||||
void Activate();
|
||||
void Destroy();
|
||||
Vector3 Position { get; set; }
|
||||
Vector3 Dimensions { get; set; }
|
||||
Vector3 Orientation { get; set; }
|
||||
// Vector3 Movement { get; set; }
|
||||
float Theta { get; set; }
|
||||
Matrix Rotation { get; set; }
|
||||
void Update(GameTime gameTime);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@ namespace EvilSatellites.Objects
|
||||
private ISoundEffect3D Sound;
|
||||
public SynthyProp(IScreen screen, Vector3 pos): base(screen)
|
||||
{
|
||||
Sound = Screen.Manager.Sound.Load3D(@"sfx/ambience/water1.wav");
|
||||
Sound = Screen.Manager.Sound.Load3D(@"sfx/ui/chat.wav");
|
||||
Sound.Loop = true;
|
||||
Position = pos;
|
||||
Sound.Position = new System.Numerics.Vector3(pos.X, pos.Y, pos.Z);
|
||||
Sound.ConnectToEffect(Screen.Manager.EnvironmentEffect);
|
||||
// Sound.ConnectToEffect(Screen.Manager.EnvironmentEffect);
|
||||
Activate();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user