-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnemy.h
71 lines (52 loc) · 1.46 KB
/
Enemy.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
#ifndef __ENEMY_H__
#define __ENEMY_H__
#include "p2Point.h"
#include "Animation.h"
struct SDL_Texture;
struct Collider;
class Enemy
{
public:
// Constructor
// Saves the spawn position for later movement calculations
Enemy(int x, int y,bool spawnRight);
// Destructor
virtual ~Enemy();
// Returns the enemy's collider
const Collider* GetCollider() const;
// Called from inhering enemies' Udpate
// Updates animation and collider position
virtual void Update();
// Called from ModuleEnemies' Update
virtual void Draw();
// Collision response
// Triggers an animation and a sound fx
virtual void OnCollision(Collider* collider);
// Sets flag for deletion and for the collider aswell
virtual void SetToDelete();
public:
// The current position in the world
iPoint position;
// The enemy's texture
SDL_Texture* texture = nullptr;
// Sound fx when destroyed
int destroyedFx = 0;
// A flag for the enemy removal. Important! We do not delete objects instantly
bool pendingToDelete = false;
// Score and Money values
uint scoreGiven = 0;
uint moneyGiven = 0;
// To know if the enemies are coming from the right
bool despawnLeft;
// 0 is NONE, 1 is Orange and 2 is Blue
uint powerupSpawn = 0;
protected:
// A ptr to the current animation
Animation* currentAnim = nullptr;
// The enemy's collider
Collider* collider = nullptr;
// Original spawn position. Stored for movement calculations
iPoint spawnPos;
int health = 0;
};
#endif // __ENEMY_H__