Skip to main content

Character

The main structure representing a player or opponent in the game, including health, mana, position, and death state management.
struct Character {
    float health = 300.0f;
    float mana = 300.0f;
    double health_timer = 0.0;
    bool draining_mana = false;
    bool is_cast = false;
    float deathTime = 0.0f;
    bool isDead = false;
    bool deathSoundPlayed = false;
    bool is_local = false;
    Vector2 pos = {};
    Rectangle rect = { 0, 0, 20, 40 };
};

Fields

health
float
default:"300.0f"
Current health points of the character. When health reaches 0, the character dies. Can exceed maximum when shields are active.
mana
float
default:"300.0f"
Current mana points used for casting spells and abilities. Drains when camera zoom is below 5.0f, regenerates above 5.0f.
health_timer
double
default:"0.0"
Timer used to track shield decay intervals. When health exceeds 300.0f, this timer counts up to 2.0 seconds before reducing health by 3.0f.
draining_mana
bool
default:"false"
Indicates whether the character is currently draining mana due to camera zoom being below the threshold (5.0f).
is_cast
bool
default:"false"
Tracks whether the character has cast a spell and projectiles are currently active in the world.
deathTime
float
default:"0.0f"
Timer for death animation fade effect. Ranges from 0.0f to 1.0f, incremented by GetFrameTime() * 0.5f when character dies.
isDead
bool
default:"false"
Indicates whether the character is currently dead. Set to true when health drops to or below 0.0f.
deathSoundPlayed
bool
default:"false"
Ensures the death sound effect plays only once per death. Reset to false when character respawns.
is_local
bool
default:"false"
Distinguishes between the local player (true) and opponents (false). Used for rendering, input handling, and network synchronization.
pos
Vector2
default:"{}"
World position coordinates of the character. Initialized randomly within safe spawn areas and updated based on movement input.
rect
Rectangle
default:"{ 0, 0, 20, 40 }"
Collision rectangle for the character with width 20 and height 40. Used for collision detection with trees and boundaries.

Ball

Represents a spell projectile cast by a character, including its appearance, trajectory, and damage properties.
struct Ball {
    Color spellColor = RED;
    Vector2 ball_pos = {};
    Vector2 target_pos = {};
    float ball_r = 25.0f;
    float ball_speed;
    float damage = 0.0f;
};

Fields

spellColor
Color
default:"RED"
Visual color of the spell projectile. Red spells (bloodRed = ) use radius 35.0f, blue spells (DARKBLUE) use default 25.0f radius.
ball_pos
Vector2
default:"{}"
Current world position of the projectile. Updated each frame based on direction and ball_speed.
target_pos
Vector2
default:"{}"
Target destination in world coordinates where the player aimed when casting. Projectile moves toward this position.
ball_r
float
default:"25.0f"
Current radius of the projectile in pixels. Decreases by 0.1f per frame and by 5.0f when colliding with trees.
ball_speed
float
Movement speed multiplier for the projectile. Red spell (KEY_ONE) uses 2.0f, blue spell (KEY_TWO) uses 4.0f.
damage
float
default:"0.0f"
Damage dealt by the projectile on impact. Calculated as 1.0f * ball_r at creation time.

PositionPacket

Network packet structure for synchronizing character positions between client and server in multiplayer mode.
struct PositionPacket {
    float x;
    float y;
};

Fields

x
float
X-coordinate of the character’s position in world space. Sent over the network when position changes.
y
float
Y-coordinate of the character’s position in world space. Sent over the network when position changes.

Build docs developers (and LLMs) love