enemy.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include "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_DEAD
  12. } EnemyState;
  13. typedef enum
  14. {
  15. ENEMY_UP,
  16. ENEMY_DOWN,
  17. ENEMY_LEFT,
  18. ENEMY_RIGHT
  19. } EnemyDirection;
  20. // EnemyContext definition
  21. typedef struct
  22. {
  23. char id[64]; // Unique ID for the enemy type
  24. int index; // Index for the specific enemy instance
  25. Vector size; // Size of the enemy
  26. Sprite *sprite_right; // Enemy sprite when looking right
  27. Sprite *sprite_left; // Enemy sprite when looking left
  28. EnemyDirection direction; // Direction the enemy is facing
  29. EnemyState state; // Current state of the enemy
  30. Vector start_position; // Start position of the enemy
  31. Vector end_position; // End position of the enemy
  32. float move_timer; // Timer for the enemy movement
  33. float elapsed_move_timer; // Elapsed time for the enemy movement
  34. float radius; // Collision radius for the enemy
  35. float speed; // Speed of the enemy
  36. float attack_timer; // Timer for the enemy attack
  37. float strength; // Damage the enemy deals
  38. float health; // Health of the enemy
  39. } EnemyContext;
  40. const EntityDescription *enemy(
  41. GameManager *manager,
  42. const char *id,
  43. int index,
  44. Vector size,
  45. Vector start_position,
  46. Vector end_position,
  47. float move_timer,
  48. float speed,
  49. float attack_timer,
  50. float strength,
  51. float health);