R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
tuning.hpp
Go to the documentation of this file.
1
3#pragma once
4#include <aegis2d/core/math.hpp>
5
6#include <chrono>
7#include <cstddef>
8#include <cstdint>
9#include <string_view>
10
12namespace rtype::tuning {
13
15inline constexpr std::uint32_t tick_rate = 60;
16
18inline constexpr std::uint32_t snapshot_rate = 20;
19static_assert(tick_rate % snapshot_rate == 0, "a snapshot every whole number of ticks");
20
22inline constexpr std::uint32_t position_history_ticks = tick_rate / 2;
25inline constexpr std::chrono::milliseconds client_interpolation_delay{100};
26
28inline constexpr float area_width = 1280.0F;
30inline constexpr float area_height = 720.0F;
31
33inline constexpr std::size_t max_players = 4;
34
36inline constexpr float player_speed = 300.0F;
38inline constexpr aegis2d::Vec2 player_size{33.0F, 17.0F};
40inline constexpr aegis2d::Vec2 player_hitbox{27.0F, 11.0F};
42inline constexpr std::int32_t player_health = 1;
44inline constexpr std::uint32_t player_lives = 3;
46inline constexpr float player_spawn_x = 100.0F;
47
49inline constexpr float player_fire_cooldown = 0.25F;
50
52inline constexpr float player_missile_speed = 900.0F;
54inline constexpr aegis2d::Vec2 player_missile_size{16.0F, 4.0F};
56inline constexpr std::int32_t player_missile_damage = 1;
57
60inline constexpr aegis2d::Vec2 bydos_size{32.0F, 32.0F};
63inline constexpr float bydos_lane_margin = 48.0F;
64
66inline constexpr std::string_view random_enemy = "bydos_slave";
68inline constexpr float bydos_spawn_min_interval = 0.8F;
70inline constexpr float bydos_spawn_max_interval = 2.0F;
72inline constexpr float bydos_spawn_x = area_width + (bydos_size.x / 2.0F);
74inline constexpr float bydos_lane_top = bydos_lane_margin + (bydos_size.y / 2.0F);
76inline constexpr float bydos_lane_bottom = area_height - bydos_lane_top;
77
79inline constexpr std::int32_t easy_enemy_health_factor = 1;
81inline constexpr float easy_spawn_interval_scale = 1.5F;
83inline constexpr std::int32_t hard_enemy_health_factor = 2;
85inline constexpr float hard_spawn_interval_scale = 0.6F;
86
88inline constexpr float enemy_missile_speed = 300.0F;
90inline constexpr aegis2d::Vec2 enemy_missile_size{8.0F, 8.0F};
92inline constexpr std::int32_t enemy_missile_damage = 1;
93
95inline constexpr std::int32_t ram_damage = 1;
96
99inline constexpr float despawn_margin = 64.0F;
100static_assert(bydos_lane_margin <= despawn_margin,
101 "a Bydos weaving off screen must not be despawned before it comes back");
102
104inline constexpr float collision_cell = 64.0F;
105
106} // namespace rtype::tuning
Values tuned for the game, in logical pixels, seconds and health points.
Definition tuning.hpp:12
constexpr float player_fire_cooldown
Seconds between two shots of a player holding fire (four shots a second).
Definition tuning.hpp:49
constexpr std::int32_t ram_damage
Damage dealt by ramming: a player ship and a Bydos hurt each other on contact.
Definition tuning.hpp:95
constexpr float bydos_spawn_max_interval
Longest time between two random Bydos spawns, in seconds.
Definition tuning.hpp:70
constexpr std::int32_t player_health
Health points of a player ship: one hit loses a life.
Definition tuning.hpp:42
constexpr std::uint32_t tick_rate
Simulation rate of the server, in ticks per second.
Definition tuning.hpp:15
constexpr float player_speed
Speed of a player ship, the same in every direction.
Definition tuning.hpp:36
constexpr float despawn_margin
Distance beyond the screen edges before a missile or an enemy is destroyed, so an enemy whose path di...
Definition tuning.hpp:99
constexpr std::int32_t easy_enemy_health_factor
Factor of the enemy health of an easy room: one missile still kills a Bydos.
Definition tuning.hpp:79
constexpr float player_missile_speed
Speed of a player missile, to the right.
Definition tuning.hpp:52
constexpr aegis2d::Vec2 player_missile_size
Size of a player missile.
Definition tuning.hpp:54
constexpr float bydos_lane_bottom
Lowest line of a random Bydos.
Definition tuning.hpp:76
constexpr float easy_spawn_interval_scale
Random Bydos spawn intervals of an easy room, times the normal ones: fewer enemies.
Definition tuning.hpp:81
constexpr std::uint32_t player_lives
Lives of a player at the start of a game.
Definition tuning.hpp:44
constexpr float hard_spawn_interval_scale
Random Bydos spawn intervals of a hard room, times the normal ones: more enemies.
Definition tuning.hpp:85
constexpr std::uint32_t snapshot_rate
Snapshots the server sends each client per second (RFC section 4.3).
Definition tuning.hpp:18
constexpr std::uint32_t position_history_ticks
Ticks of enemy positions the server keeps, for lag compensation: 500 ms.
Definition tuning.hpp:22
constexpr float bydos_spawn_x
x of the random spawns: a Bydos appears just beyond the right edge.
Definition tuning.hpp:72
constexpr float collision_cell
Side of a cell of the collision grid, about the size of a Bydos.
Definition tuning.hpp:104
constexpr float bydos_lane_top
Highest line of a random Bydos, so that it weaves without leaving the screen.
Definition tuning.hpp:74
constexpr std::int32_t enemy_missile_damage
Damage of an enemy missile.
Definition tuning.hpp:92
constexpr float bydos_spawn_min_interval
Shortest time between two random Bydos spawns, in seconds.
Definition tuning.hpp:68
constexpr float enemy_missile_speed
Speed of an enemy missile, to the left.
Definition tuning.hpp:88
constexpr std::chrono::milliseconds client_interpolation_delay
How far behind the server a client draws the world, as the server assumes it for lag compensation: th...
Definition tuning.hpp:25
constexpr std::string_view random_enemy
Enemy type the random spawns create, from assets/enemies.
Definition tuning.hpp:66
constexpr float player_spawn_x
Distance of the player spawns from the left edge.
Definition tuning.hpp:46
constexpr aegis2d::Vec2 enemy_missile_size
Size of an enemy missile.
Definition tuning.hpp:90
constexpr aegis2d::Vec2 player_size
Size of a player ship on screen.
Definition tuning.hpp:38
constexpr aegis2d::Vec2 bydos_size
Size of a Bydos slave, as the clients draw it: width and height of assets/enemies/bydos_slave....
Definition tuning.hpp:60
constexpr std::size_t max_players
Players in one game, as the subject requires.
Definition tuning.hpp:33
constexpr std::int32_t player_missile_damage
Damage of a player missile.
Definition tuning.hpp:56
constexpr aegis2d::Vec2 player_hitbox
Hit box of a player ship, a little smaller than its sprite.
Definition tuning.hpp:40
constexpr float bydos_lane_margin
Room kept above and below the line of a random Bydos for its weave: the amplitude of assets/enemies/b...
Definition tuning.hpp:63
constexpr std::int32_t hard_enemy_health_factor
Factor of the enemy health of a hard room: a Bydos takes two missiles.
Definition tuning.hpp:83
constexpr float area_height
Height of the play area (logical resolution).
Definition tuning.hpp:30
constexpr float area_width
Width of the play area (logical resolution).
Definition tuning.hpp:28