wall collision

This commit is contained in:
Vinzenz Schroeter 2024-04-07 18:18:26 +02:00
parent 54b840da3e
commit dd6b0fffc1
6 changed files with 68 additions and 39 deletions

View file

@ -1,3 +1,8 @@
using TanksServer.Services;
namespace TanksServer.Models;
internal record struct FloatPosition(double X, double Y);
internal readonly record struct FloatPosition(double X, double Y)
{
public PixelPosition ToPixelPosition() => new((int)X % MapService.PixelsPerRow, (int)Y % MapService.PixelsPerRow);
}

View file

@ -3,13 +3,16 @@ namespace TanksServer.Models;
internal sealed class Tank(Player player, FloatPosition spawnPosition)
{
private double _rotation;
public Player Owner { get; } = player;
/// <summary>
/// Bounds: 0 (inclusive) .. 16 (exclusive)
/// </summary>
public double Rotation
{
get => _rotation;
set => _rotation = value % 16d;
set => _rotation = (value + 16d) % 16d;
}
public FloatPosition Position { get; set; } = spawnPosition;