Game Development Reference
In-Depth Information
When the player collides with the enemy, its dead flag is set to true, which will
cause the game to end. The game is now partially playable with an outcome for
losing or winning. From this point on, the refinements to the game will start to
make it more fun to play.
Introducing Simple Weapons
Weapons in the game mainly take the form of different types of bullets. A good
goal to aim for is to have the player shoot a bullet each time the A button or
spacebar is pressed. Eventually the enemies will also be firing bullets, which is
important to bear in mind when creating the bullet system.
To experiment with bullets, another texture is needed. Find bullet.tga on the CD
in Assets directory and add it to the project, remembering to set the properties as
before. Then this texture needs to be loaded into the texture manager.
_textureManager.LoadTexture("bullet", "bullet.tga");
Once the texture is loaded, the next logical class to create is the Bullet class.
This will have a bounding box and a sprite so it too can inherit from Entity .
The class should be created in the Shooter project.
public class Bullet : Entity
{
public bool Dead { get; set; }
public Vector Direction { get; set; }
public double Speed { get; set; }
public double X
{
get { return _sprite.GetPosition().X; }
}
public double Y
{
get { return _sprite.GetPosition().Y; }
}
public void SetPosition(Vector position)
{
_sprite.SetPosition(position);
 
Search WWH ::




Custom Search