#ifndef PLAYER_H #define PLAYER_H #include "twn_game_api.h" typedef struct World World; typedef enum PlayerAction { PLAYER_ACTION_GROUND, PLAYER_ACTION_FALL, PLAYER_ACTION_JUMP, } PlayerAction; typedef struct Player { World *world; /* visual */ float sprite_w; float sprite_h; /* body */ Rect rect; /* state */ PlayerAction action; /* physics */ Rect collider_x; Rect collider_y; int collider_thickness; float dx; float dy; float max_dx; float run_horizontal_speed; float horizontal_damping; float current_gravity_multiplier; float terminal_velocity; /* jumping */ float jump_force_initial; float jump_force_increase; /* aka "jump power", increment of dy per tick */ int jump_air_ticks; int jump_air_timer; int jump_coyote_ticks; int jump_coyote_timer; int jump_buffer_ticks; int jump_buffer_timer; /* gravity multipliers */ float jump_default_multiplier; float jump_boosted_multiplier; float jump_corner_correction_offset; /* from center */ } Player; Player *player_create(World *world); void player_destroy(Player *player); void player_calc(Player *player); #endif