-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathSimplexCamera.cs
More file actions
42 lines (37 loc) · 1.18 KB
/
Copy pathSimplexCamera.cs
File metadata and controls
42 lines (37 loc) · 1.18 KB
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
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
namespace SimplexCore
{
[Serializable]
public class SimplexCamera
{
public OrthographicCamera Camera;
public Vector2 TargetPosition;
public Vector2 Position;
public float TransformSpeed;
public float Zoom;
public float TargetZoom;
public float Rotation;
public void UpdatePosition()
{
float newX = (float)Sgml.lerp_aggressive(Position.X, TargetPosition.X, TransformSpeed);
float newY = (float)Sgml.lerp_aggressive(Position.Y, TargetPosition.Y, TransformSpeed);
float newZoom = (float)Sgml.lerp_aggressive(Zoom, TargetZoom, TransformSpeed);
Position.X = newX;
Position.Y = newY;
Zoom = newZoom;
Camera.Position = new Vector2(newX, newY);
Camera.Zoom = (float)Sgml.clamp(Zoom, 0.05, 30);
Camera.Rotation = Rotation;
//Camera.Origin = new Vector2(0, 0);
}
public SimplexCamera()
{
Zoom = 1;
TargetZoom = 1;
}
}
}