Aegis2D
Modular C++26 2D game engine for networked games
Loading...
Searching...
No Matches
aegis2d::ecs::SineMotion Struct Reference

Sine wave added to an entity's movement, like an enemy weaving up and down. More...

#include <aegis2d/ecs/components.hpp>

Public Attributes

Vec2 amplitude {}
 Largest offset from the path, in logical pixels, and its direction: {0, 48} weaves 48 pixels up and down. Zero by default: no motion.
 
float period = 1.0F
 Seconds for one full wave; a period of zero or less does not move the entity.
 
float elapsed = 0.0F
 Seconds into the current wave, kept in [0, period). Starting above 0 shifts the phase, so the enemies of a group do not move in step.
 

Detailed Description

Sine wave added to an entity's movement, like an enemy weaving up and down.

ecs::apply_sine_motion() moves the entity by the change of amplitude * sin(2π * elapsed / period) over each tick, on top of its Velocity: an enemy flying left with a vertical amplitude weaves around a horizontal line. The offset follows the time, not the number of ticks, so the path is the same at any tick rate. The motion is not part of Velocity, so give an entity that also has OffscreenDespawn a margin of at least the amplitude.

Member Data Documentation

◆ amplitude

Vec2 aegis2d::ecs::SineMotion::amplitude {}

Largest offset from the path, in logical pixels, and its direction: {0, 48} weaves 48 pixels up and down. Zero by default: no motion.

◆ elapsed

float aegis2d::ecs::SineMotion::elapsed = 0.0F

Seconds into the current wave, kept in [0, period). Starting above 0 shifts the phase, so the enemies of a group do not move in step.

◆ period

float aegis2d::ecs::SineMotion::period = 1.0F

Seconds for one full wave; a period of zero or less does not move the entity.


The documentation for this struct was generated from the following file: