using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace TankBattleCore.Objects; struct BulletData { public Vector2 Position; public float Angle; public float Speed; } class Bullet { public const float SlowSpeed = 250f; public const float FastSpeed = 400f; private Vector2 _position; private Texture2D _bulletTexture; float _speed; float _angle; public Vector2 Position { get => _position; } public Bullet(Vector2 position, Texture2D bulletTexture, float speed, float angle) { _position = position; _bulletTexture = bulletTexture; _speed = speed; _angle = angle; } public void Update(float dt) { _position += new Vector2(MathF.Cos(_angle), MathF.Sin(_angle)) * _speed * dt; } public void Draw(SpriteBatch spriteBatch) { spriteBatch.Draw( _bulletTexture, _position, Color.White ); } }