-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.cs
More file actions
47 lines (41 loc) · 1.2 KB
/
Camera.cs
File metadata and controls
47 lines (41 loc) · 1.2 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
43
44
45
46
47
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System;
using System.Collections.Generic;
using System.Text;
namespace PokeMan
{
public class Camera
{
public Vector2 position;
public Vector2 offset;
public int Width { get; private set; }
public int Height { get; private set; }
public Camera()
{
Width = PokeManGame.SceenSize.x;
Height = PokeManGame.SceenSize.y;
offset = new Vector2(-Width, -Height);
}
/// <summary>
/// Gives World position to screen
/// </summary>
/// <param name="worldCoords"></param>
/// <returns></returns>
public Vector2 WorldToScreen(Vector2 worldCoords)
{
return worldCoords - position - offset / 2;
}
/// <summary>
/// Gives screen position to world
/// </summary>
/// <param name="screenCoords"></param>
/// <returns></returns>
public Vector2 ScreenToWorld(Vector2 screenCoords)
{
return screenCoords + position + offset / 2;
}
}
}