Camera speed dependent on time
This commit is contained in:
@@ -1,53 +1,55 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
|
||||||
namespace DepthsBelow
|
namespace DepthsBelow
|
||||||
{
|
{
|
||||||
public class Camera
|
public class Camera
|
||||||
{
|
{
|
||||||
public float Zoom;
|
public float Zoom;
|
||||||
public Matrix Transform;
|
public Matrix Transform;
|
||||||
public Vector2 Position;
|
public Vector2 Position;
|
||||||
public float Rotation;
|
public float Rotation;
|
||||||
|
|
||||||
public float Speed;
|
public float Speed;
|
||||||
|
|
||||||
private Core core;
|
private Core core;
|
||||||
|
|
||||||
public Camera(Core core)
|
public Camera(Core core)
|
||||||
{
|
{
|
||||||
this.core = core;
|
this.core = core;
|
||||||
|
|
||||||
Zoom = 1.0f;
|
Zoom = 1.0f;
|
||||||
Rotation = 0.0f;
|
Rotation = 0.0f;
|
||||||
Position = Vector2.Zero;
|
Position = Vector2.Zero;
|
||||||
Speed = 5;
|
Speed = 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(GameTime gameTime)
|
public void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
MouseState ms = Mouse.GetState();
|
float elapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
|
||||||
|
|
||||||
if (ms.X < 20)
|
MouseState ms = Mouse.GetState();
|
||||||
Position.X -= Speed;
|
|
||||||
if (ms.X > core.GraphicsDevice.Viewport.Width - 20)
|
if (ms.X < 20)
|
||||||
Position.X += Speed;
|
Position.X -= Speed * elapsed;
|
||||||
|
if (ms.X > core.GraphicsDevice.Viewport.Width - 20)
|
||||||
if (ms.Y < 20)
|
Position.X += Speed * elapsed;
|
||||||
Position.Y -= Speed;
|
|
||||||
if (ms.Y > core.GraphicsDevice.Viewport.Height - 20)
|
if (ms.Y < 20)
|
||||||
Position.Y += Speed;
|
Position.Y -= Speed * elapsed;
|
||||||
|
if (ms.Y > core.GraphicsDevice.Viewport.Height - 20)
|
||||||
Transform =
|
Position.Y += Speed * elapsed;
|
||||||
Matrix.CreateTranslation(new Vector3(-Position.X, -Position.Y, 0))
|
|
||||||
* Matrix.CreateRotationZ(Rotation)
|
Transform =
|
||||||
* Matrix.CreateScale(Zoom)
|
Matrix.CreateTranslation(new Vector3(-Position.X, -Position.Y, 0))
|
||||||
//* Matrix.CreateTranslation(new Vector3(
|
* Matrix.CreateRotationZ(Rotation)
|
||||||
;
|
* Matrix.CreateScale(Zoom)
|
||||||
}
|
//* Matrix.CreateTranslation(new Vector3(
|
||||||
}
|
;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ namespace DepthsBelow
|
|||||||
graphics.PreferredBackBufferHeight = 720;
|
graphics.PreferredBackBufferHeight = 720;
|
||||||
graphics.IsFullScreen = false;
|
graphics.IsFullScreen = false;
|
||||||
|
|
||||||
|
graphics.SynchronizeWithVerticalRetrace = false;
|
||||||
|
this.IsFixedTimeStep = false;
|
||||||
|
graphics.ApplyChanges();
|
||||||
|
|
||||||
this.IsMouseVisible = true;
|
this.IsMouseVisible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user