Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
Projectile.h
Go to the documentation of this file.
1
2#pragma once
3
4#include "KatanaEngine.h"
5#include "GameObject.h"
6
8class Projectile : public GameObject
9{
10
11public:
12
14 Projectile();
15 virtual ~Projectile() { }
16
19 static void SetTexture(Texture *pTexture) { s_pTexture = pTexture; }
20
23 virtual void Update(const GameTime& gameTime);
24
27 virtual void Draw(SpriteBatch& spriteBatch);
28
32 virtual void Activate(const Vector2 &position, bool wasShotByPlayer = true);
33
36 virtual float GetDamage() const { return m_damage; }
37
40 virtual std::string ToString() const;
41
44 virtual CollisionType GetCollisionType() const;
45
46
47protected:
48
51 virtual void SetSpeed(const float speed) { m_speed = speed; }
52
55 virtual void SetDamage(const float damage) { m_damage = damage; }
56
59 virtual void SetDirection(const Vector2 direction) { m_direction = direction; }
60
63 virtual float GetSpeed() const { return m_speed; }
64
67 virtual Vector2 &GetDirection() { return m_direction; }
68
71 virtual bool WasShotByPlayer() const { return m_wasShotByPlayer; }
72
76
77
78private:
79
80 static Texture *s_pTexture;
81
82 float m_speed = 500; // pixels per second
83 float m_damage = 1;
84
85 Vector2 m_direction;
86
87 bool m_wasShotByPlayer = true;
88};
89
Represents a type of collision.
static const CollisionType Projectile
Represents a game object in the game. This is the base class for all objects that can be updated,...
Definition GameObject.h:15
virtual void Activate()
Activate the object.
Definition GameObject.h:45
Contains timing values for game updates and rendering.
Definition GameTime.h:21
Enables a group of sprites to be drawn using the same settings.
Definition SpriteBatch.h:48
Represents a 2D grid of texels.
Definition Texture.h:21
Defines a vector with 2 components (x and y).
Definition Vector2.h:21
Represents a projectile that can be fired by a weapon.
Definition Projectile.h:9
static void SetTexture(Texture *pTexture)
Set the texture that will be used to render the projectile.
Definition Projectile.h:19
virtual CollisionType GetProjectileType() const
Get the collision type of the projectile.
Definition Projectile.h:75
virtual CollisionType GetCollisionType() const
Get the type of collision the projectile will have.
virtual bool WasShotByPlayer() const
Determine if the projectile was fired by the player.
Definition Projectile.h:71
virtual float GetSpeed() const
Get the speed of the projectile.
Definition Projectile.h:63
virtual float GetDamage() const
Get the amount of damage the projectile will deal.
Definition Projectile.h:36
virtual void SetDirection(const Vector2 direction)
Set the direction of the projectile.
Definition Projectile.h:59
virtual void SetDamage(const float damage)
Set the amount of damage the projectile will deal.
Definition Projectile.h:55
virtual void SetSpeed(const float speed)
Set the speed of the projectile.
Definition Projectile.h:51
Projectile()
Instantiate a projectile object.
Definition Projectile.cpp:7
virtual std::string ToString() const
Get the string representation of the projectile.
virtual void Draw(SpriteBatch &spriteBatch)
Render the projectile.
virtual ~Projectile()
Definition Projectile.h:15
virtual Vector2 & GetDirection()
Get the direction of the projectile.
Definition Projectile.h:67
virtual void Update(const GameTime &gameTime)
Update the projectile.