diff options
Diffstat (limited to 'enemy.h')
-rw-r--r-- | enemy.h | 68 |
1 files changed, 68 insertions, 0 deletions
@@ -0,0 +1,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 |