Hi I'm making an game which is bit of an asteroids clone
I'm having trouble making the bullet code to make it fire from the player ship
Here's my attempt of the bullet code
public class Bullet : Ship
{
private Sprite _BulletSprite;
public List<Bullet> Bullets = new List<Bullet>();
// Bullet Constructor
public Bullet(String name, float SpawnX, float SpawnY)
{
//_BulletSprite = Graphics.CreateSprite(Resources.GameImage("bullet"), 2, 2, 30, 30);
for (int i = 0; i < Bullets.Count; i++)
{
Bullets.Add(new Bullet(name, SpawnX, SpawnY));
Bullets[i]._BulletSprite = Graphics.CreateSprite(Resources.GameImage("bullet"), 2, 2, 50, 50);
Bullets[i]._BulletSprite.X = SpawnX;
Bullets[i]._BulletSprite.Y = SpawnY;
}
}
public void updateBullet()
{
if (Input.IsKeyPressed(SwinGame.Keys.VK_SPACE))
{
Bullets.Add(new Bullet("bullet", _playership.X + 16, _playership.Y - 2));
}
}
public void drawBullet()
{
for (int i = 0; i < Bullets.Count; i++)
{
Graphics.DrawSprite(Bullets[i]._BulletSprite);
//Graphics.DrawSprite(_BulletSprite);
}
}
}