separate folders per functionality
This commit is contained in:
parent
7f00160780
commit
0ca6a91a7e
1 changed files with 60 additions and 113 deletions
21
TanksServer/GameLogic/MoveBullets.cs
Normal file
21
TanksServer/GameLogic/MoveBullets.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
namespace TanksServer.GameLogic;
|
||||
|
||||
internal sealed class MoveBullets(BulletManager bullets) : ITickStep
|
||||
{
|
||||
public Task TickAsync()
|
||||
{
|
||||
foreach (var bullet in bullets.GetAll())
|
||||
MoveBullet(bullet);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private static void MoveBullet(Bullet bullet)
|
||||
{
|
||||
var angle = bullet.Rotation / 16 * 2 * Math.PI;
|
||||
bullet.Position = new FloatPosition(
|
||||
X: bullet.Position.X + Math.Sin(angle) * 3,
|
||||
Y: bullet.Position.Y - Math.Cos(angle) * 3
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in a new issue