move backend to subfolder
This commit is contained in:
parent
d4d1f2f981
commit
8d09663eff
80 changed files with 98 additions and 88 deletions
48
tanks-backend/TanksServer/Graphics/GamePixelGrid.cs
Normal file
48
tanks-backend/TanksServer/Graphics/GamePixelGrid.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace TanksServer.Graphics;
|
||||
|
||||
internal sealed class GamePixelGrid : IEnumerable<GamePixel>
|
||||
{
|
||||
public int Width { get; }
|
||||
public int Height { get; }
|
||||
|
||||
private readonly GamePixel[,] _pixels;
|
||||
|
||||
public GamePixelGrid(int width, int height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
|
||||
_pixels = new GamePixel[width, height];
|
||||
for (var y = 0; y < height; y++)
|
||||
for (var x = 0; x < width; x++)
|
||||
this[x, y] = new GamePixel();
|
||||
}
|
||||
|
||||
public GamePixel this[int x, int y]
|
||||
{
|
||||
get
|
||||
{
|
||||
Debug.Assert(y * Width + x < _pixels.Length);
|
||||
return _pixels[x, y];
|
||||
}
|
||||
set => _pixels[x, y] = value;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
foreach (var pixel in _pixels)
|
||||
pixel.Clear();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
|
||||
public IEnumerator<GamePixel> GetEnumerator()
|
||||
{
|
||||
for (var y = 0; y < Height; y++)
|
||||
for (var x = 0; x < Width; x++)
|
||||
yield return this[x, y];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue