From 1b6ecc22e77b7aa1fee16420b041c1dea1925052 Mon Sep 17 00:00:00 2001 From: riton Date: Sat, 29 Mar 2025 21:37:46 +0300 Subject: init repo --- enemy.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 enemy.h (limited to 'enemy.h') diff --git a/enemy.h b/enemy.h new file mode 100644 index 0000000..ae362bd --- /dev/null +++ b/enemy.h @@ -0,0 +1,68 @@ +#ifndef DUSMAN_H +#define DUSMAN_H + +#include +#include +#include +#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 -- cgit v1.2.3