-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathenemy.h
69 lines (52 loc) · 1.47 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
#ifndef enemy_h
#define enemy_h
#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_image.h>
#include "enemy.h"
#include "utility.h"
#include "map.h"
#include "player.h"
typedef enum{
slime,
} enemyType;
typedef enum{
ALIVE, DYING, DEAD
} EnemyStatus;
typedef struct _enemy{
ALLEGRO_BITMAP* image;
enemyType type;
Point coord;
int speed;
int health;
EnemyStatus status;
// Knockback
float knockback_angle;
uint8_t knockback_CD;
// Animation
DIRECTION dir;
uint8_t animation_tick;
uint8_t animation_hit_tick;
uint8_t death_animation_tick;
} Enemy;
// Create an enemy in specified row col and the type
Enemy createEnemy(int row, int col, char type);
// Return true if the enemy is death by hit
void hitEnemy(Enemy * enemy, int damage, float angle);
/*
Struct of 1 node of enemy
We use linked list data structure to store enemy information
Since the enemy might die at one point, linked list will be better here since the deletion is O(1)
*/
typedef struct _enemyNode {
Enemy enemy;
struct _enemyNode * next;
} enemyNode;
enemyNode * createEnemyList(void);
void insertEnemyList(enemyNode * dummyhead, Enemy _enemy);
void updateEnemyList(enemyNode * dummyhead, Map * map, Player * player);
void drawEnemyList(enemyNode * dummyhead, Point cam);
void destroyEnemyList(enemyNode * dummyhead);
void initEnemy(void);
void terminateEnemy(void);
#endif