public void CheckInput(Starfighter starfighter) { CheckPlayers(); if (players.Count > 0) { //Better to link starship to single player and acquire through skeletonid //but this will do for testing foreach (var player in players) { left = player.Value.GetJointPosition(JointID.HandLeft); right = player.Value.GetJointPosition(JointID.HandRight); centre = player.Value.GetJointPosition(JointID.ShoulderCenter); } //THis starts the flight once the player exists and has raised hands //(well, moved them far enough from centre) //Although this is a fixed width and prob ought to be calculated //based upon player height. if(starfighter.Speed == 0 && left.X < centre.X - 0.2 && right.X > centre.X + 0.2) { starfighter.Speed = 20; } if (left.Y > right.Y - 0.15 ) MoveRight(starfighter); if (left.Y < right.Y + 0.15 ) MoveLeft(starfighter); if (left.Z < (centre.Z - 0.2) && right.Z < (centre.Z - 0.2)) DecreaseSpeed(starfighter); if (left.Z > (centre.Z + 0.2) && right.Z > (centre.Z + 0.2)) IncreaseSpeed(starfighter); } }
public void CheckInput(Starfighter starfighter) { if (starfighter.Speed == 0 && Keyboard.IsKeyDown(Key.Up)) starfighter.Speed = 19; if(Keyboard.IsKeyDown(Key.Left)) MoveLeft(starfighter); if(Keyboard.IsKeyDown(Key.Right)) MoveRight(starfighter); if(Keyboard.IsKeyDown(Key.Up)) IncreaseSpeed(starfighter); if(Keyboard.IsKeyDown(Key.Down)) DecreaseSpeed(starfighter); }