enemy.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #include <game/game.h>
  3. #include "flip_world.h"
  4. typedef enum
  5. {
  6. ENEMY_IDLE,
  7. ENEMY_MOVING,
  8. ENEMY_MOVING_TO_START,
  9. ENEMY_MOVING_TO_END,
  10. ENEMY_ATTACKING,
  11. ENEMY_ATTACKED,
  12. ENEMY_DEAD
  13. } EnemyState;
  14. typedef enum
  15. {
  16. ENEMY_UP,
  17. ENEMY_DOWN,
  18. ENEMY_LEFT,
  19. ENEMY_RIGHT
  20. } EnemyDirection;
  21. // EnemyContext definition
  22. typedef struct
  23. {
  24. char id[64]; // Unique ID for the enemy type
  25. int index; // Index for the specific enemy instance
  26. Vector size; // Size of the enemy
  27. Sprite *sprite_right; // Enemy sprite when looking right
  28. Sprite *sprite_left; // Enemy sprite when looking left
  29. EnemyDirection direction; // Direction the enemy is facing
  30. EnemyState state; // Current state of the enemy
  31. Vector start_position; // Start position of the enemy
  32. Vector end_position; // End position of the enemy
  33. float move_timer; // Timer for the enemy movement
  34. float elapsed_move_timer; // Elapsed time for the enemy movement
  35. float radius; // Collision radius for the enemy
  36. float speed; // Speed of the enemy
  37. float attack_timer; // Cooldown duration between attacks
  38. float elapsed_attack_timer; // Time elapsed since the last attack
  39. float strength; // Damage the enemy deals
  40. float health; // Health of the enemy
  41. } EnemyContext;
  42. const EntityDescription *enemy(
  43. GameManager *manager,
  44. const char *id,
  45. int index,
  46. Vector start_position,
  47. Vector end_position,
  48. float move_timer, // Wait duration before moving again
  49. float speed,
  50. float attack_timer,
  51. float strength,
  52. float health);
  53. void spawn_enemy_json_furi(Level *level, GameManager *manager, FuriString *json);