summaryrefslogtreecommitdiff
path: root/src/characters.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/characters.h')
-rw-r--r--src/characters.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/characters.h b/src/characters.h
new file mode 100644
index 0000000..2f1e10b
--- /dev/null
+++ b/src/characters.h
@@ -0,0 +1,100 @@
+#pragma once
+
+#include "raylib.h"
+#include "entity.h"
+#include "array.h"
+
+typedef enum {
+ AA_IDLE = 0,
+ AA_CHARGE = 1,
+ AA_ATTACK = 2,
+} AttackAnimState;
+
+typedef enum {
+ C_IDLE = 0,
+ C_OBSERVE = 1,
+ C_PATROL = 2,
+ C_FOLLOW = 3,
+ C_AGGRO = 4,
+ C_HIT = 5,
+ C_DEAD = 6
+} CharState;
+
+typedef enum {
+ AI_NONE = 0,
+ AI_IDLE = 1,
+ AI_PATROL = 2,
+ AI_DETECT = 3,
+ AI_ATTACK = 4,
+} AIState;
+
+typedef enum {
+ HA_IDLE = 0,
+ HA_PLAY = 1,
+} HitAnimState;
+
+typedef enum {
+ PATROL_TOP = 0,
+ PATROL_LEFT = 1,
+ PATROL_DOWN = 2,
+ PATROL_RIGHT = 3,
+} PatrolDir;
+
+typedef struct Entity AttackedEntity;
+typedef struct Entity AggroEntity;
+typedef struct Entity FriendEntity;
+
+struct Character {
+ bool isburning;
+ EntityType type; // TROLL / BANDIT
+ int entity_id;
+ CharState state; // CharState
+ int tile_id; // MapSymbol
+ int home_tile_id; // MapSymbol
+ AIState ai_state;
+ int health;
+ float speed_multiplier;
+ float move_speed;
+ float detection_threshold;
+ float attack_threshold;
+ // improved idle behavior
+ PatrolDir patrol_dir;
+ bool to_core_pos;
+ Vector2 core_position; // this is the main position characters will stick to
+ double t_idle_start; // time spent at core position, useful to rotate them out
+ // of positions
+ float t_idle_duration; // max allowed duration they should be idle
+
+ Vector2 position;
+ Vector2 last_enemy_position;
+ Vector2 move_dir;
+ Vector2 target_position;
+ Rectangle target_rect;
+ Rectangle render_rect;
+ Color tint_color_base;
+ Color tint_color_active;
+ Color tint_color;
+ Texture2D *sprite;
+ // AggroEntity attackers[2];
+ EntityArrayList attackers;
+ // FriendEntity friends[2];
+ EntityArrayList friends;
+ //
+ // Animation
+ //
+ // getting hit
+ HitAnimState anim_hit_state;
+ float anim_hit_speed;
+ double t_anim_hit_start;
+ float t_anim_hit_duration;
+ // getting burned
+ double t_anim_burn_start;
+
+ // attacking
+ int anim_attack_state;
+ float anim_attack_speed;
+ float t_anim_charge_duration;
+ float t_anim_attack_duration;
+ double t_anim_charge_start;
+ double t_anim_attack_start;
+};