infinite map
This commit is contained in:
parent
7213318838
commit
461a9139c2
20 changed files with 101 additions and 69 deletions
|
@ -12,6 +12,7 @@ internal sealed class DrawStateToFrame(
|
|||
|
||||
public Task TickAsync()
|
||||
{
|
||||
// TODO: fix race condition with shared buffer access
|
||||
_drawGrid.Clear();
|
||||
foreach (var step in _drawSteps)
|
||||
step.Draw(_drawGrid);
|
||||
|
|
|
@ -7,8 +7,8 @@ internal sealed class MapDrawer(MapService map) : IDrawStep
|
|||
{
|
||||
public void Draw(PixelGrid buffer)
|
||||
{
|
||||
for (var tileY = 0; tileY < MapService.TilesPerColumn; tileY++)
|
||||
for (var tileX = 0; tileX < MapService.TilesPerRow; tileX++)
|
||||
for (ushort tileY = 0; tileY < MapService.TilesPerColumn; tileY++)
|
||||
for (ushort tileX = 0; tileX < MapService.TilesPerRow; tileX++)
|
||||
{
|
||||
var tile = new TilePosition(tileX, tileY);
|
||||
if (!map.IsCurrentlyWall(tile))
|
||||
|
|
|
@ -33,16 +33,16 @@ internal sealed class TankDrawer : IDrawStep
|
|||
{
|
||||
foreach (var tank in _tanks)
|
||||
{
|
||||
var pos = tank.Position.ToPixelPosition();
|
||||
var rotationVariant = (int)Math.Round(tank.Rotation) % 16;
|
||||
var tankPosition = tank.Position.ToPixelPosition();
|
||||
var orientation = (int)Math.Round(tank.Rotation * 16d) % 16;
|
||||
|
||||
for (var dy = 0; dy < MapService.TileSize; dy++)
|
||||
for (var dx = 0; dx < MapService.TileSize; dx++)
|
||||
for (byte dy = 0; dy < MapService.TileSize; dy++)
|
||||
for (byte dx = 0; dx < MapService.TileSize; dx++)
|
||||
{
|
||||
if (!TankSpriteAt(dx, dy, rotationVariant))
|
||||
if (!TankSpriteAt(dx, dy, orientation))
|
||||
continue;
|
||||
|
||||
var position = new PixelPosition((ushort)(pos.X + dx), (ushort)(pos.Y + dy));
|
||||
var position = tankPosition.GetPixelRelative(dx, dy);
|
||||
buffer[position.X, position.Y] = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue