Added 3D Variant, still nedds improvment

This commit is contained in:
Jan Grießhaber
2024-10-24 16:16:43 +02:00
parent 73c8cbca39
commit 1bb56adceb
14 changed files with 577 additions and 33 deletions

View File

@@ -81,7 +81,7 @@ namespace SFMLGame
//DrawAll(ref window, ref objects);
watch.Restart();
window.Draw(GetFPSText(CurrentFPS, font));
DrawFPSText(CurrentFPS, font, ref window);
window.Draw(GetCellCountText(CellCount, font));
window.Draw(GetIterationText(game.Iteration, font));
@@ -150,7 +150,7 @@ namespace SFMLGame
private static Drawable GetCellCountText(int value, Font font)
{
Text ret = new Text($"CellCOunt: {value}", font);
Text ret = new Text($"Cell Count: {value}", font);
ret.Position = new Vector2f(0, 40);
return ret;
}
@@ -184,11 +184,13 @@ namespace SFMLGame
//game.getActiveMap().GetCell(e.Y/4, e.X/4).isAlive = true;
}
private static Text GetFPSText(int currentFPS, Font font)
private static void DrawFPSText(int currentFPS, Font font, ref RenderWindow window)
{
Text txt = new($"FPS: {currentFPS}", font);
return txt;
window.Draw(txt);
txt.Dispose();
}
private static void Render(in GameMap gameMap, ref VertexArray vtx)
@@ -204,32 +206,11 @@ namespace SFMLGame
private static void Render(in GameMap gameMap, out int DrawCalls, ref RenderWindow window)
{
/**
drawables = [];//int ctn=0;
var sizeScalar = new Vector2f(4f, 4f);
RectangleShape shape = new(sizeScalar);
int drawCalls = 0;
foreach (var cell in gameMap.GetAllCells())
{
shape.Position = new Vector2f(cell.YCoord * 4, cell.XCoord * 4);
//shape.Scale = new(2f, 2f);
//shape.Radius = 1f;
//shape.Size = sizeScalar;
shape.FillColor = GetColor(cell);
shape.OutlineThickness = 1f;
shape.OutlineColor = Color.Black;
//window.Draw(shape);
window.Draw(shape);
drawCalls++;
//drawables.Add(shape);
//ctn++;
//vtx.Append(new Vertex(new Vector2f(cell.YCoord * 4, cell.XCoord * 4), GetColor(cell)));
}**/
//shape.Dispose();
#if DEBUG
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
stopwatch.Start();
#endif
var sizeScalar = new Vector2f(4f, 4f);
DrawCalls = 0;
VertexArray vtx = new VertexArray(PrimitiveType.Quads);
@@ -256,11 +237,13 @@ namespace SFMLGame
}
window.Draw(vtx);
vtx.Dispose();
if(dmsg)
#if DEBUG
if (dmsg)
{
Console.WriteLine($"Drawing took {stopwatch.ElapsedMilliseconds}ms | {stopwatch.ElapsedTicks}ticks");
}
stopwatch.Stop();
stopwatch.Stop();
#endif
//Console.WriteLine($"Draw Calls per Frame: {drawCalls}");
return;
}