Initial spaceship
This commit is contained in:
Binary file not shown.
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace EvilSatellites
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
DavyKager.Tolk.Load();
|
||||
using (var game = new Game1())
|
||||
game.Run();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using Microsoft.Xna.Framework.Input;
|
||||
using SynthySound;
|
||||
using System.Linq;
|
||||
using EvilSatellites.Objects;
|
||||
using DavyKager;
|
||||
|
||||
namespace EvilSatellites.Screens
|
||||
{
|
||||
@@ -15,11 +16,19 @@ namespace EvilSatellites.Screens
|
||||
public ScreenState State { get; set; }
|
||||
public List<IGameObject> Objects = new List<IGameObject>();
|
||||
private float Theta = 0;
|
||||
private Player _player;
|
||||
private ISoundEffect radarNoise;
|
||||
public void Activate()
|
||||
{
|
||||
State = ScreenState.Active;
|
||||
Player player = new Player(this);
|
||||
Objects.Add(player);
|
||||
_player = player;
|
||||
SynthyProp prop = new SynthyProp(this, new Vector3(15, 0, 15));
|
||||
Objects.Add(prop);
|
||||
radarNoise = Manager.Sound.Load(@"sfx/ui/voiceError.wav", false);
|
||||
radarNoise.Loop = true;
|
||||
radarNoise.Play();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -28,6 +37,7 @@ namespace EvilSatellites.Screens
|
||||
State = ScreenState.Hidden;
|
||||
return;
|
||||
}
|
||||
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
foreach (var obj in Objects)
|
||||
@@ -35,22 +45,54 @@ namespace EvilSatellites.Screens
|
||||
obj.Update(gameTime);
|
||||
if (obj.Type == ObjectType.Player)
|
||||
{
|
||||
// obj.TranslateForward();
|
||||
Manager.Sound.ListenerPosition = new System.Numerics.Vector3(obj.Position.X, obj.Position.Y, obj.Position.Z);
|
||||
Manager.Sound.ListenerOrientationForward = System.Numerics.Vector3.Normalize(new System.Numerics.Vector3(obj.Rotation.Forward.X, obj.Rotation.Forward.Y, obj.Rotation.Forward.Z));
|
||||
Manager.Sound.ListenerOrientationUpwards = System.Numerics.Vector3.Normalize(new System.Numerics.Vector3(obj.Rotation.Up.X, obj.Rotation.Up.Y, obj.Rotation.Up.Z));
|
||||
Manager.Listener.Position = obj.Position;
|
||||
Manager.Listener.Forward = obj.Rotation.Forward;
|
||||
Manager.Listener.Up = obj.Rotation.Up;
|
||||
// Console.WriteLine(Manager.Sound.ListenerOrientationForward);
|
||||
// Console.WriteLine(Manager.Sound.ListenerOrientationUpwards);
|
||||
}
|
||||
}
|
||||
Vector3 radarTarget = (Objects[1].Position - _player.Position);
|
||||
radarTarget.Normalize();
|
||||
radarNoise.Pitch = MathHelper.Clamp(0.1f / Vector3.Distance(_player.Rotation.Forward, radarTarget)*3f, 0, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
public void HandleInput(GameTime gameTime, KeyboardState inputs)
|
||||
{
|
||||
if (inputs.IsKeyDown(Keys.W))
|
||||
{
|
||||
_player.Accelerate();
|
||||
}
|
||||
if (inputs.IsKeyDown(Keys.Left))
|
||||
{
|
||||
_player.RotateY(0.05f);
|
||||
}
|
||||
if (inputs.IsKeyDown(Keys.Right))
|
||||
{
|
||||
_player.RotateY(-0.05f);
|
||||
}
|
||||
if (inputs.IsKeyDown(Keys.Up))
|
||||
{
|
||||
_player.RotateX(0.05f);
|
||||
}
|
||||
if (inputs.IsKeyDown(Keys.Down))
|
||||
{
|
||||
_player.RotateX(-0.05f);
|
||||
}
|
||||
if (inputs.IsKeyDown(Keys.V))
|
||||
{
|
||||
Tolk.Speak(_player.Movement.Length().ToString(), true);
|
||||
}
|
||||
if (inputs.IsKeyDown(Keys.X))
|
||||
{
|
||||
Tolk.Speak(radarNoise.Pitch.ToString(), true);
|
||||
}
|
||||
if (inputs.IsKeyDown(Keys.C))
|
||||
{
|
||||
Tolk.Speak(_player.Position.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8d47cb047800cfbd9189404b46991b7e2c5d1623a37cb1d235e34b5389d90cbd
|
||||
size 2778404
|
||||
oid sha256:70cee281d65bdf707d46e5ecba24c98ae6066b85965fd930826becaedf78a532
|
||||
size 2508512
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b77babc3153c25d827a353c6f8acccee57b562364dd33ddfbbaea4afba9ed83c
|
||||
size 3146198
|
||||
oid sha256:79fc765256e9b99f1b34de78fcbc38b6685caecf1b3b948896c04a8285eebe86
|
||||
size 2876306
|
||||
|
||||
Reference in New Issue
Block a user