-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputManager.cs
More file actions
41 lines (36 loc) · 1.3 KB
/
InputManager.cs
File metadata and controls
41 lines (36 loc) · 1.3 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
using Cosmos.System;
using Cosmos.System.Graphics;
using System.Drawing;
using Cosmos.System.Graphics.Fonts;
namespace IronOS
{
public class InputManager
{
public int MouseX = 400;
public int MouseY = 300;
public bool Clicked = false;
public void Update()
{
Clicked = false;
if (KeyboardManager.TryReadKey(out var key))
{
switch (key.Key)
{
case ConsoleKeyEx.UpArrow: MouseY = System.Math.Max(0, MouseY - 5); break;
case ConsoleKeyEx.DownArrow: MouseY = System.Math.Min(599, MouseY + 5); break;
case ConsoleKeyEx.LeftArrow: MouseX = System.Math.Max(0, MouseX - 5); break;
case ConsoleKeyEx.RightArrow: MouseX = System.Math.Min(799, MouseX + 5); break;
case ConsoleKeyEx.Spacebar: Clicked = true; break;
}
}
}
public void DrawCursor(Canvas canvas)
{
Pen cursorPen = new Pen(Color.Yellow);
canvas.DrawPoint(cursorPen, MouseX, MouseY);
canvas.DrawPoint(cursorPen, MouseX + 1, MouseY);
canvas.DrawPoint(cursorPen, MouseX, MouseY + 1);
canvas.DrawPoint(cursorPen, MouseX + 1, MouseY + 1);
}
}
}