We will start by creating a class to represent the catapult projectiles. Both players fire projectiles and they need to behave in accordance to the laws of physics, taking the wind into account as well. Add a new class under the “Catapult” folder and name it Projectile.
Add the following using statements to the top of the newly created file:
As the projectile represents an entity that will be drawn on screen, change the Projectile class to inherit from the DrawableGameComponent class.
class Projectile : DrawableGameComponent
Note: Do not forget to alter the new class’s namespace as we have done previously.
Add the following field and property definitions to the Projectile class:
// Textures for projectile
// Position and speed of projectile
Vector2 projectileVelocity = Vector2.Zero;
Vector2 projectileRotationPosition = Vector2.Zero;
public Vector2 ProjectileStartPosition
projectileStartPosition = value;
Page | 50