From 25fdc90968a14ffd44dae65d6fdb3d50e6df9082 Mon Sep 17 00:00:00 2001 From: BoredGuy Date: Fri, 27 Mar 2026 16:29:32 -0700 Subject: Initial Commit --- TankBattleCore/Objects/Bullet.cs | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 TankBattleCore/Objects/Bullet.cs (limited to 'TankBattleCore/Objects/Bullet.cs') diff --git a/TankBattleCore/Objects/Bullet.cs b/TankBattleCore/Objects/Bullet.cs new file mode 100644 index 0000000..0775d22 --- /dev/null +++ b/TankBattleCore/Objects/Bullet.cs @@ -0,0 +1,47 @@ +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 + ); + } +} \ No newline at end of file -- cgit v1.2.3