-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemy.h
More file actions
37 lines (30 loc) · 1.23 KB
/
Enemy.h
File metadata and controls
37 lines (30 loc) · 1.23 KB
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
#ifndef ENEMY_H
#define ENEMY_H
#include "Weapon.h"
#include "Character.h"
// Virtual class used for enemy characters in the game
class Enemy : public Character
{
protected:
int xp; // Experience points awarded for defeating the enemy
float updateInterval; // Time between AI updates
clock_t lastUpdate; // Last time the AI was updated
public:
// Default constructor
Enemy();
// Parameterized constructor
// Inputs: radius, position, speed, health, weapon, xp, updateInterval
Enemy(int r, sf::Vector2f position, sf::Color color, float speed, int health, Weapon *weapon, int xp, float updateInterval);
// Returns "enemy"
// Output: string "enemy"
std::string getType() override;
// Pure virtual function: updates the AI of the enemy and returns a projectile if it attacks
// Input: playerPosition (current position of the player)
// Output: optional Projectile if attack occurs, otherwise std::nullopt
// This function must be implemented by derived classes (enemy types)
virtual std::optional<Projectile> updateAI(sf::Vector2f playerPosition) = 0;
// Returns the experience points awarded for defeating the enemy
// Output: experience points
int getxp();
};
#endif