implement fast bullets

This commit is contained in:
Vinzenz Schroeter 2024-04-29 16:59:37 +02:00
parent 9ccb7c8df8
commit 9164d90443
7 changed files with 30 additions and 24 deletions

View file

@ -1,9 +1,6 @@
namespace TanksServer.GameLogic;
internal sealed class MoveBullets(
MapEntityManager entityManager,
IOptions<GameRules> config
) : ITickStep
internal sealed class MoveBullets(MapEntityManager entityManager) : ITickStep
{
public ValueTask TickAsync(TimeSpan delta)
{
@ -13,9 +10,9 @@ internal sealed class MoveBullets(
return ValueTask.CompletedTask;
}
private void MoveBullet(Bullet bullet, TimeSpan delta)
private static void MoveBullet(Bullet bullet, TimeSpan delta)
{
var speed = config.Value.BulletSpeed * delta.TotalSeconds;
var speed = bullet.Speed * delta.TotalSeconds;
var angle = bullet.Rotation * 2 * Math.PI;
bullet.Position = new FloatPosition(
bullet.Position.X + Math.Sin(angle) * speed,