Manages player character state, movement, animations, and interactions. More...
#include <vec2.h>#include <animation.h>#include <stdbool.h>#include <gun.h>#include <particle_emitterpresets.h>#include <colliders.h>#include <game.h>#include <sound.h>Go to the source code of this file.
Classes | |
| struct | SkillState |
| struct | SkillResources |
| struct | SkillStat |
| struct | PlayerState |
| Contains the player's current state information. More... | |
| struct | PlayerResources |
| Contains the player's resources and timers. More... | |
| struct | PlayerStat |
| Contains the player's stats and attributes. More... | |
| struct | PlayerData |
| Main player data structure. More... | |
Typedefs | |
| typedef enum PlayerPassive | PlayerPassive |
| typedef struct SkillState | SkillState |
| typedef struct SkillResources | SkillResources |
| typedef struct SkillStat | SkillStat |
| typedef struct PlayerState | PlayerState |
| Contains the player's current state information. | |
| typedef struct PlayerResources | PlayerResources |
| Contains the player's resources and timers. | |
| typedef struct PlayerStat | PlayerStat |
| Contains the player's stats and attributes. | |
| typedef struct PlayerData | PlayerData |
| Main player data structure. | |
Enumerations | |
| enum | PlayerPassive { ARMORED_UP , GHOST_LOAD , HEMO_CYCLE , KINETIC_ARMOR , LAST_STAND , OVER_PRESSURED , SCAVENGER , TOTAL_SKILLS } |
Functions | |
| void | Player_Input_Handler () |
| Handles player input. | |
| int | Player_Render () |
| Renders the player. | |
| int | Player_Start () |
| Initializes the player. | |
| int | Player_PostUpdate () |
| Post-update operations for player. | |
| int | Player_Preupdate () |
| Pre-update operations for player. | |
| bool | Player_DetectCollision () |
| Detects collisions for player. | |
| int | Player_Move () |
| Moves the player. | |
| int | Player_Look (Vec2 direction) |
| Makes player look in specified direction. | |
| void | Player_UpdateHitbox () |
| Updates player hitbox. | |
| int | Player_Dash () |
| Initiates player dash. | |
| int | Player_HandleDash () |
| Handles ongoing dash state. | |
| int | Player_CrashOut () |
| Activates crashout ability. | |
| int | Player_HandleCrashOut () |
| Handles ongoing crashout state. | |
| void | Player_Shoot () |
| Makes player shoot current weapon. | |
| void | Player_SwitchGun () |
| Changes player's current weapon. | |
| int | Player_AnimationInit () |
| Initializes player animations. | |
| int | Player_AnimationUpdate () |
| Updates player animations. | |
| void | Skill_Update () |
| void | scavenger () |
| void | Player_TakeDamage (int damage) |
| void | Player_RenderDamageEffect () |
| bool | kineticArmor () |
| bool | ghostLoad () |
| int | Parry () |
| int | Handle_ParryRender () |
| int | Handle_Parry () |
| void | Player_PickUpGun (void *data, int interactableIndex) |
| Picks up a gun. | |
| void | Player_OpenCrate (void *data, int interactableIndex) |
| Opens a crate This function is a callback when the player interacts with a closed crate. | |
| void | Player_ReadLog (void *data, int interactableIndex) |
Variables | |
| PlayerData | player |
| Global player instance. | |
Manages player character state, movement, animations, and interactions.
| typedef struct PlayerData PlayerData |
Main player data structure.
| typedef enum PlayerPassive PlayerPassive |
| typedef struct PlayerResources PlayerResources |
Contains the player's resources and timers.
| typedef struct PlayerStat PlayerStat |
Contains the player's stats and attributes.
| typedef struct PlayerState PlayerState |
Contains the player's current state information.
| typedef struct SkillResources SkillResources |
| typedef struct SkillState SkillState |
| enum PlayerPassive |
| bool ghostLoad | ( | ) |
| int Handle_Parry | ( | ) |
| int Handle_ParryRender | ( | ) |
| bool kineticArmor | ( | ) |
| int Parry | ( | ) |
| int Player_AnimationInit | ( | ) |
Initializes player animations.
Initializes player animations.
Creates and sets up the player's animation system from the animation data defined in player_data.c.
| int Player_AnimationUpdate | ( | ) |
Updates player animations.
Updates player animations.
Selects the appropriate animation based on player state (idle or walking) and advances the animation frames.
| int Player_CrashOut | ( | ) |
Activates crashout ability.
Activates crashout ability.
Takes 25% of the player's current health and gives a 2x damage multiplier for 15 seconds. Has a cooldown before it can be used again.
| int Player_Dash | ( | ) |
Initiates player dash.
Initiates player dash.
Activates the dash ability if off cooldown and player has directional input. Plays dash sound effect and locks direction during dash.
| bool Player_DetectCollision | ( | ) |
Detects collisions for player.
Detects collisions for player.
Detects if the player is colliding with any objects in the game world and triggers the appropriate response based on collision type.
| int Player_HandleCrashOut | ( | ) |
Handles ongoing crashout state.
Handles ongoing crashout state.
Updates visual effects, checks duration, and resets state when completed.
| int Player_HandleDash | ( | ) |
Handles ongoing dash state.
Handles ongoing dash state.
This is called every frame player.state.dashing is true. Updates dash particle effects and handles dash movement.
| void Player_Input_Handler | ( | ) |
Handles player input.
Handles player input.
Checks keyboard and mouse input to trigger player actions including movement, dashing, weapon switching, and shooting.
| int Player_Look | ( | Vec2 | direction | ) |
Makes player look in specified direction.
| direction | Direction vector |
Makes player look in specified direction.
Updates the player's direction vector and sets appropriate movement speed. Ignores input if the direction is locked (e.g., during a dash).
| direction | The direction to move the player in |
| int Player_Move | ( | ) |
Moves the player.
Moves the player.
Applies the player's direction and speed to position, handles collision checking, and updates movement state flags.
| void Player_OpenCrate | ( | void * | data, |
| int | interactableIndex | ||
| ) |
Opens a crate This function is a callback when the player interacts with a closed crate.
| data | The gun data |
| interactableIndex | The index of the interactable crate. |
| void Player_PickUpGun | ( | void * | data, |
| int | interactableIndex | ||
| ) |
Picks up a gun.
This function is a callback when the player interacts with a gun on the ground.
| data | The gun data |
| interactableIndex | The index of the interactable gun on the ground. |
| int Player_PostUpdate | ( | ) |
Post-update operations for player.
Post-update operations for player.
This function is called inside App_PostUpdate(). It updates the player's input, position, and animations in sequence.
| int Player_Preupdate | ( | ) |
Pre-update operations for player.
Pre-update operations for player.
Clears movement and location flags to ensure they're recalculated each frame, and resets direction vector if not locked.
| void Player_ReadLog | ( | void * | data, |
| int | interactableIndex | ||
| ) |
| int Player_Render | ( | ) |
Renders the player.
Renders the player.
Draws the player's character sprite and dash particle effects at the appropriate screen position. Flips the sprite based on mouse cursor position.
| void Player_RenderDamageEffect | ( | ) |
| void Player_Shoot | ( | ) |
Makes player shoot current weapon.
Makes player shoot current weapon.
Activates the shooting sequence, including sound effects, particle effects for muzzle flash and casings, and creating bullet projectiles.
| int Player_Start | ( | ) |
Initializes the player.
Initializes the player.
This function is called in App_Start(). It initializes the player's animations and sets the player's current gun to the pistol. Also sets up collision, particle effects, and timers.
| void Player_SwitchGun | ( | ) |
Changes player's current weapon.
Changes player's current weapon.
| void Player_TakeDamage | ( | int | damage | ) |
| void Player_UpdateHitbox | ( | ) |
Updates player hitbox.
Updates player hitbox.
Recalculates the position of the player's collision hitbox to match their current world position, with appropriate offsets.
| void scavenger | ( | ) |
| void Skill_Update | ( | ) |
|
extern |
Global player instance.
Global player instance.
Contains all default values for the player including position, collision properties, movement speeds, sprite data, and animation definitions.