forked from bepu/bepuphysics1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FreeCameraControlScheme.cs
51 lines (46 loc) · 1.73 KB
/
FreeCameraControlScheme.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
namespace BEPUphysicsDemos
{
public class FreeCameraControlScheme : CameraControlScheme
{
/// <summary>
/// Gets or sets the speed at which the camera moves.
/// </summary>
public float Speed { get; set; }
public FreeCameraControlScheme(float speed, Camera camera, DemosGame game)
: base(camera, game)
{
Speed = speed;
}
public override void Update(float dt)
{
base.Update(dt);
//Only move around if the camera has control over its own position.
float distance = Speed * dt;
#if XBOX360
MoveForward(Game.GamePadInput.ThumbSticks.Left.Y * distance);
MoveRight(gamePadInput.ThumbSticks.Left.X * distance);
if (Game.GamePadInput.IsButtonDown(Buttons.LeftStick))
MoveUp(distance);
if (Game.GamePadInput.IsButtonDown(Buttons.RightStick))
MoveUp(-distance);
#endif
if (Game.KeyboardInput.IsKeyDown(Keys.E))
Camera.MoveForward(distance);
if (Game.KeyboardInput.IsKeyDown(Keys.D))
Camera.MoveForward(-distance);
if (Game.KeyboardInput.IsKeyDown(Keys.S))
Camera.MoveRight(-distance);
if (Game.KeyboardInput.IsKeyDown(Keys.F))
Camera.MoveRight(distance);
if (Game.KeyboardInput.IsKeyDown(Keys.A))
Camera.MoveUp(distance);
if (Game.KeyboardInput.IsKeyDown(Keys.Z))
Camera.MoveUp(-distance);
}
}
}