Overview
The Player is a specialized character entity that represents a playable character in the game. Players can be controlled via keyboard/mouse or gamepad, render to individual canvases, and support split-screen multiplayer.Function Reference
player_new()
Creates and initializes a new player entity.Pointer to the game instance
Pointer to the window instance
Character identifier for configuration lookup. Valid values:
'N', 'S', 'E', 'W' for spawn directionPointer to the newly created player, or
NULL on allocation failureStructure Definition
s_player
The player structure extendst_character with rendering and controller properties.
Base character data (see Characters)
Individual render canvas for this player (split-screen support)
Last recorded canvas position for rendering optimization
Controller identifier for input mapping
Whether this player can damage other players. Configurable via map type
FRIENDLY_FIREConfiguration
Players are configured through map type identifiers. The following constants define player behavior:Player Constants
Maximum ray distance when no collision detected
Field of view in degrees
Number of sub-rays for improved collision detection
Mouse look sensitivity multiplier
Keyboard look rotation speed in degrees per second
Walking speed in units per second
Sprinting speed in units per second
Maximum number of entities detected per ray
Maximum distance for entity interaction/targeting
Player collision width in map units
Player collision height in map units
Maximum number of simultaneous players (split-screen limit)
Delay in milliseconds before respawning after death
Spawn Direction
The identifier determines initial player orientation:'N'- North (yaw: 270.0°)'S'- South (yaw: 90.0°)'E'- East (yaw: 0.0°)'W'- West (yaw: 180.0°)
Map Type Configuration
Players can be customized via map type properties:Controller type. Set to
"PLAYER" for player-controlled entities"TRUE" to enable damage between players, "FALSE" to disable (default: TRUE)Path to collision sound effect
Example
See Also
- Characters - Base character functionality
- Items - Player inventory and weapons
- Game Objects - Game instance management