summaryrefslogtreecommitdiff
path: root/TankBattleCore/Objects/Bullet.cs
diff options
context:
space:
mode:
authorBoredGuy <osome3717@gmail.com>2026-03-27 16:29:32 -0700
committerBoredGuy <osome3717@gmail.com>2026-03-27 16:29:32 -0700
commit25fdc90968a14ffd44dae65d6fdb3d50e6df9082 (patch)
tree3e11812a480ff173a7c65fd9d53e0efc69f5be27 /TankBattleCore/Objects/Bullet.cs
Initial Commit
Diffstat (limited to 'TankBattleCore/Objects/Bullet.cs')
-rw-r--r--TankBattleCore/Objects/Bullet.cs47
1 files changed, 47 insertions, 0 deletions
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