RogueLife/src/entities.h

77 lines
1.7 KiB
C
Raw Normal View History

//---
// entities: Objects that move around the map
//---
#pragma once
#include "geometry.h"
2021-06-04 15:14:12 +02:00
//---
// Agents
//---
2021-06-02 16:45:02 +02:00
typedef struct {
2021-06-05 11:38:51 +02:00
/* Maximum walking speed (m/s) */
2021-06-04 15:14:12 +02:00
fixed_t max_speed;
2021-06-05 11:38:51 +02:00
/* Rate a which target speed is approached (1/s) */
fixed_t propulsion;
/* Peak dash speed (m/s) */
fixed_t dash_speed;
/* Dash duration (s) */
fixed_t dash_duration;
/* Dash cooldown (s) */
fixed_t dash_cooldown;
2021-06-04 16:24:47 +02:00
2021-06-04 15:14:12 +02:00
} entity_movement_params_t;
typedef struct {
/* Current position */
2021-06-02 16:45:02 +02:00
fixed_t x, y;
2021-06-04 15:14:12 +02:00
/* Current speed */
fixed_t vx, vy;
2021-06-05 11:38:51 +02:00
/* Dash time remaining (if positive) or cooldown remaining (if negative) */
fixed_t dash;
/* Direction currently facing */
2021-06-04 15:14:12 +02:00
uint8_t facing;
2021-06-05 11:38:51 +02:00
/* Dash direction */
uint8_t dash_facing;
2021-06-04 15:14:12 +02:00
} entity_movement_t;
/* Alive agents with hitboxes and movement control */
typedef struct {
/* Hitbox, centered around (movement.x, movement.y) */
shape_t hitbox;
/* Current cinematic situation */
entity_movement_t movement;
/* Cinematic parameters */
entity_movement_params_t const *movement_params;
2021-06-02 16:45:02 +02:00
} entity_t;
2021-06-04 15:14:12 +02:00
/* Entity position */
fpoint_t entity_pos(entity_t const *e);
2021-06-02 16:45:02 +02:00
2021-06-05 11:38:51 +02:00
/* Update walk/sprint movement (stand still if direction == -1); this cinematic
state can be submitted for collisions and may or may not be accpeted */
2021-06-04 15:14:12 +02:00
entity_movement_t entity_move(entity_t *e, int direction, fixed_t dt);
2021-06-05 11:38:51 +02:00
/* Start dashing in the set direction */
void entity_dash(entity_t *e, int direction);
2021-06-02 16:45:02 +02:00
2021-06-04 15:14:12 +02:00
/* Unit vector in the direction the entity is facing */
2021-06-02 16:45:02 +02:00
fpoint_t entity_facing(entity_t const *e);
2021-06-04 15:14:12 +02:00
//---
// Particles
//---
/* Particles with no interaction but visual effects */
typedef struct {
/* Location and speed */
fixed_t x, y;
fixed_t vx, vy;
} particle_t;