-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleRenderer.cs
More file actions
46 lines (41 loc) · 1.15 KB
/
ConsoleRenderer.cs
File metadata and controls
46 lines (41 loc) · 1.15 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Maze1
{
public class ConsoleRenderer
{
private char[,] _pixels;
private char[,] _previousPixels;
private int _width;
private int _height;
public ConsoleRenderer()
{
_width = Console.WindowWidth;
_height = Console.WindowHeight;
_pixels = new char[_width, _height];
_previousPixels = new char[_width, _height];
Console.CursorVisible = false;
}
public void SetPixel(int w, int h, char val)
{
_pixels[w, h] = val;
}
public void Render()
{
for (int w = 0; w < _width; w++)
{
for (int h = 0; h < _height; h++)
{
if (_previousPixels[w, h] == _pixels[w, h])
continue;
Console.SetCursorPosition(w, h);
Console.Write(_pixels[w, h]);
_previousPixels[w, h] = _pixels[w, h];
}
}
}
}
}