R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
ship_movement.hpp
Go to the documentation of this file.
1
3#pragma once
4#include <aegis2d/core/math.hpp>
5#include <aegis2d/ecs/components.hpp>
6#include <aegis2d/ecs/registry.hpp>
7#include <aegis2d/ecs/system.hpp>
8
9namespace rtype {
10
12struct ShipMotion {
14 aegis2d::Vec2 position;
16 aegis2d::Vec2 velocity;
17
20 bool operator==(const ShipMotion&) const = default;
21};
22
28[[nodiscard]] aegis2d::Vec2 ship_velocity(aegis2d::ecs::PlayerInput input) noexcept;
29
35[[nodiscard]] aegis2d::Vec2 keep_ship_in_area(aegis2d::Vec2 position) noexcept;
36
46[[nodiscard]] ShipMotion step_ship(aegis2d::Vec2 position, aegis2d::ecs::PlayerInput input,
47 float delta) noexcept;
48
54void steer_ships(aegis2d::ecs::Registry& registry, const aegis2d::ecs::Tick& tick);
55
61void keep_ships_in_area(aegis2d::ecs::Registry& registry, const aegis2d::ecs::Tick& tick);
62
63} // namespace rtype
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
aegis2d::Vec2 ship_velocity(aegis2d::ecs::PlayerInput input) noexcept
Velocity of a player ship holding an input.
void steer_ships(aegis2d::ecs::Registry &registry, const aegis2d::ecs::Tick &tick)
System that sets the velocity of every player ship from its input.
void keep_ships_in_area(aegis2d::ecs::Registry &registry, const aegis2d::ecs::Tick &tick)
System that keeps every player ship inside the play area.
aegis2d::Vec2 keep_ship_in_area(aegis2d::Vec2 position) noexcept
Keeps a player ship inside the play area.
ShipMotion step_ship(aegis2d::Vec2 position, aegis2d::ecs::PlayerInput input, float delta) noexcept
Moves a player ship by one tick.
Where a player ship is and how it moves, after a step.
Definition ship_movement.hpp:12
aegis2d::Vec2 velocity
Velocity, in logical pixels per second.
Definition ship_movement.hpp:16
aegis2d::Vec2 position
Center of the ship, in logical pixels.
Definition ship_movement.hpp:14
bool operator==(const ShipMotion &) const =default
Field-by-field equality.