-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModuleEnemies.h
103 lines (78 loc) · 2.33 KB
/
ModuleEnemies.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef __MODULE_ENEMIES_H__
#define __MODULE_ENEMIES_H__
#include "Module.h"
#define MAX_ENEMIES 100
// Create new enemy types:
enum class ENEMY_TYPE
{
NO_TYPE,
MEDIUMCAMOUFLAGEJET,
BIGORANGEJET,
BIGCAMOUFLAGEJET,
BLUEJET,
GREENFIGHTERPLANE,
SMALLCAMOUFLAGEJET,
STEALTHBOMBER,
TRUCK,
TURRET
};
struct EnemySpawnpoint
{
ENEMY_TYPE type = ENEMY_TYPE::NO_TYPE;
int x, y;
bool spawnRight;
};
class Enemy;
struct SDL_Texture;
class ModuleEnemies : public Module
{
public:
// Constructor
ModuleEnemies(bool startEnabled);
// Destructor
~ModuleEnemies();
// Called when the module is activated
// Loads the necessary textures for the enemies
bool Start() override;
// Called at the beginning of the application loop
// Removes all enemies pending to delete
update_status PreUpdate() override;
// Called at the middle of the application loop
// Handles all enemies logic and spawning/despawning
update_status Update() override;
// Called at the end of the application loop
// Iterates all the enemies and draws them
update_status PostUpdate() override;
// Called on application exit
// Destroys all active enemies left in the array
bool CleanUp() override;
// Called when an enemi collider hits another collider
// The enemy is destroyed and an explosion particle is fired
void OnCollision(Collider* c1, Collider* c2) override;
// Add an enemy into the queue to be spawned later
bool AddEnemy(ENEMY_TYPE type, int x, int y, bool spawnRight = true);
// Iterates the queue and checks for camera position
void HandleEnemiesSpawn();
// Destroys any enemies that have moved outside the camera limits
void HandleEnemiesDespawn();
//Texture for the Stealth Bomber Boss
SDL_Texture* sbTexture = nullptr;
//Texture for the GreenFighter SubBoss
SDL_Texture* gfTexture = nullptr;
int shootBossFx = 0;
private:
// Spawns a new enemy using the data from the queue
void SpawnEnemy(const EnemySpawnpoint& info);
private:
// A queue with all spawn points information
EnemySpawnpoint spawnQueue[MAX_ENEMIES];
// All spawned enemies in the scene
Enemy* enemies[MAX_ENEMIES] = { nullptr };
// The enemies sprite sheet
SDL_Texture* texture = nullptr;
// Texture for the enemies of level 1
SDL_Texture* truckTexture = nullptr;
// The audio fx for destroying an enemy
int enemyDestroyedFx = 0;
};
#endif // __MODULE_ENEMIES_H__