-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRenderer.cs
63 lines (52 loc) · 1.76 KB
/
Renderer.cs
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Drawing;
using Map;
using Frames;
using Pastel;
class Renderer
{
private static int Width = 80;
private static int Height = 40;
private static Frame PrevFrame = null;
public static void Render (Frame F)
{
/*
The renderer will only render flattened frames.
*/
if (PrevFrame == null)
PrintFrame(F);
else
Update(F);
PrevFrame = F;
}
public static void PrintFrame(Frame F)
{
int xOffset = 0;
int yOffset = 0;
Console.Clear();
for (int y = 0; y < F.Product.height; y++) //F.Product.height
{
for (int u = 0; u < F.Product.width; u++) //F.Product.width
{
if (F.Product[0, y, u].ColorValue == null)
Console.Write(F.Product[0, y + yOffset, u + xOffset].Character );
else
Console.Write($"{(F.Product[0, y + yOffset, u + xOffset].Character + "").Pastel(F.Product[0, y + yOffset, u + xOffset].ColorValue ?? default(Color))}");
}
Console.WriteLine();
}
}
public static void Update(Frame F)
{
//change Product indicing to indice with coord struct
foreach (Coord change in FrameTools.Contrast(PrevFrame, F))
{
Console.SetCursorPosition(change.x, change.y);
if (F.Product[change].ColorValue == null)
Console.Write(F.Product[change].Character);
else
Console.Write($"{(F.Product[change].Character + "").Pastel(F.Product[change].ColorValue ?? default(Color))}");
}
PrevFrame = F;
}
}