Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
EnemyShip.cpp
Go to the documentation of this file.
1
2#include "EnemyShip.h"
3
4
10
11
12void EnemyShip::Update(const GameTime& gameTime)
13{
14 if (m_delaySeconds > 0)
15 {
16 m_delaySeconds -= gameTime.GetElapsedTime();
17
18 if (m_delaySeconds <= 0)
19 {
21 }
22 }
23
24 if (IsActive())
25 {
26 m_activationSeconds += gameTime.GetElapsedTime();
27 if (m_activationSeconds > 2 && !IsOnScreen()) Deactivate();
28 }
29
30 Ship::Update(gameTime);
31}
32
33
34void EnemyShip::Initialize(const Vector2 position, const double delaySeconds)
35{
36 SetPosition(position);
37 m_delaySeconds = delaySeconds;
38
40}
41
42
43void EnemyShip::Hit(const float damage)
44{
45 Ship::Hit(damage);
46}
virtual void Hit(const float damage)
Applies damage to the ship.
Definition EnemyShip.cpp:43
virtual void Update(const GameTime &gameTime)
Loads the content for the enemy ship.
Definition EnemyShip.cpp:12
EnemyShip()
Creates a new instance of EnemyShip.
Definition EnemyShip.cpp:5
virtual void SetPosition(const float x, const float y)
virtual void SetCollisionRadius(const int radius)
Definition GameObject.h:98
virtual bool IsOnScreen() const
virtual void Activate()
Activate the object.
Definition GameObject.h:45
virtual bool IsActive() const
Flag to determine if the object is active.
Definition GameObject.h:42
virtual void Deactivate()
Deactivate the object.
Definition GameObject.h:48
Contains timing values for game updates and rendering.
Definition GameTime.h:21
double GetElapsedTime() const
Gets the time in seconds since last frame.
Definition GameTime.h:30
Defines a vector with 2 components (x and y).
Definition Vector2.h:21
virtual void Update(const GameTime &gameTime)
Updates the ship.
Definition Ship.cpp:14
virtual void Hit(const float damage)
Applies damage to the ship.
Definition Ship.cpp:26
virtual void SetMaxHitPoints(const float hitPoints)
Sets the max hit points of the ship.
Definition Ship.h:63
virtual void Initialize()
Initializes the ship.
Definition Ship.cpp:56