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
|
#ifndef DUSMAN_H
#define DUSMAN_H
#include <raylib.h>
#include <math.h>
#include <stdbool.h>
#include "sprite-animator.h"
#include "matematik.h"
#include "player.h"
#include "textures.h"
enum enemy_type {
TEST_ENEMY,
SKELETON,
ENEMY_TYPE_COUNT
};
typedef struct Enemy {
animation_player_t animation;
enum enemy_type type;
int health;
int health_max;
Vector2 position;
Vector2 size;
/* Vector2 center; */
Vector2 direction;
Rectangle hitbox;
Vector2 hb_offset;
int speed;
int active;
} enemy_t;
animation_player_t get_enemy_animation(enum enemy_type type);
Rectangle get_enemy_hitbox(enum enemy_type type);
/* enemy_t make_test_enemy(Texture2D *texture, int max_health, int x, int y, int speed); */
enemy_t make_enemy(enum enemy_type type, int max_health, int x, int y, int speed);
void draw_enemy(enemy_t *enemy);
void move_enemy(enemy_t* e, float dt);
void flip_enemy_y_axis(enemy_t *enemy);
void update_test_enemy(enemy_t *e, Vector2 target, float dt);
void update_enemy_basic(enemy_t *e, Vector2 target, float dt);
void update_enemy(enemy_t *e, Vector2 target, float dt);
typedef struct EnemySpawner {
Rectangle border;
float cooldown_max;
float cooldown;
} enemy_spawner_t;
enemy_t spawn_enemy(enemy_spawner_t* spawner);
void update_spawner(enemy_spawner_t* spawner, float dt);
void start_cooldown(enemy_spawner_t* spawner);
bool can_spawn(const enemy_spawner_t* spawner);
/* Vector2 enemy_health = (Vector2){ */
/* .x = 5, */
/* .y = 5 */
/* }; */
/* void draw_enemy(enemy_t *enemy){ */
/* DrawRectangleV(enemy->position, enemy->size, RED); */
/* /\* DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color) *\/ */
/* } */
#endif
|