-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
45 lines (37 loc) · 1.47 KB
/
Program.cs
File metadata and controls
45 lines (37 loc) · 1.47 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
using PixelWindowSystem;
using SFML.Graphics;
var appManager = new RandomPixelsAppManager();
var window = new PixelWindow(1024, 576, 8, "Big pixels", appManager,
fixedTimestep: 20, framerateLimit: 300, showPerformanceMetricsInTitleBar: true);
window.Run();
// All we need to do is implement the methods in IPixelWindowAppManager and pass in an instance of this class to the
// PixelWindow constructor, as above.
class RandomPixelsAppManager : IPixelWindowAppManager
{
private Random _rand = new();
public void OnLoad(RenderWindow renderWindow)
{
// On load function - runs once at start.
// The SFML render window provides ability to set up events and input (maybe store a reference to it for later use in your update functions)
}
public void Update(float frameTime)
{
// Update function - process update logic to run every frame here
}
public void FixedUpdate(float timeStep)
{
// Fixed update function - process logic to run every fixed timestep here
}
public void Render(PixelData pixelData, float frameTime)
{
// Render function - set pixel data for the current frame here
// Randomised pixels shown as example.
for (uint x = 0; x < pixelData.Width; x++)
{
for (uint y = 0; y < pixelData.Height; y++)
{
pixelData[x, y] = ((byte)_rand.Next(0, 255), (byte)_rand.Next(0, 255), (byte)_rand.Next(0, 255));
}
}
}
}