MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
space::Ship Class Reference

Mutable gameplay and movement state for a player ship. More...

#include <examples/asteroids-net/ship.hpp>

Public Member Functions

glm::vec3 forward () const
 Returns the normalized world-space direction in which the ship points.
glm::vec3 forward () const

Public Attributes

int burst_count = 0
 Shots already fired in the current burst.
float camera_distance = 6.0f
 Third-person camera distance.
float camera_height = 1.6f
 Third-person camera height.
int continuous_fire_timer = 0
 Timer controlling continuous fire.
float current_speed = 1.0f
 Current forward speed.
bool exploding = false
 Whether the ship is currently exploding.
int explosion_timer = 0
 Remaining explosion animation frames.
int fire_cooldown = 0
 Frames remaining before the next shot is allowed.
int lives = 5
 Remaining lives.
float max_speed = 25.0f
 Maximum controllable speed.
float min_speed = 0.1f
 Minimum controllable speed.
int overheat_cooldown = 0
 Frames remaining in the overheat cooldown.
bool overheated = false
 Whether firing is disabled by overheating.
float pitch_speed_multiplier = 0.55f
 Pitch rate relative to the yaw rate.
glm::vec3 position {0.0f, 0.0f, 0.0f}
 Current world-space position.
glm::vec3 prev_position {0.0f, 0.0f, 0.0f}
 Position from the previous simulation step.
glm::vec3 rotation {0.0f}
 Euler rotation in degrees.
int score = 0
 Current score.
float turn_speed = 140.0f
 Yaw rate in degrees per second.
glm::vec3 velocity {0.0f}
 Current world-space velocity.
bool visible = true
 Whether the ship is rendered.

Detailed Description

Mutable gameplay and movement state for a player ship.

Definition at line 17 of file ship.hpp.

Member Function Documentation

◆ forward() [1/2]

glm::vec3 Ship::forward ( ) const

Returns the normalized world-space direction in which the ship points.

Definition at line 5 of file ship.cpp.

5 {
6 glm::mat4 rot(1.0f);
7 rot = glm::rotate(rot, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
8 rot = glm::rotate(rot, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
9 return normalize_or_zero(glm::vec3(rot * glm::vec4(0.0f, 0.0f, -1.0f, 0.0f)));
10 }
glm::vec3 rotation
Euler rotation in degrees.
Definition ship.hpp:26
glm::vec3 normalize_or_zero(const glm::vec3 &value)
Normalizes a direction with a stable fallback.

◆ forward() [2/2]

glm::vec3 space::Ship::forward ( ) const

Member Data Documentation

◆ burst_count

int Ship::burst_count = 0

Shots already fired in the current burst.

Definition at line 54 of file ship.hpp.

◆ camera_distance

float Ship::camera_distance = 6.0f

Third-person camera distance.

Definition at line 38 of file ship.hpp.

◆ camera_height

float Ship::camera_height = 1.6f

Third-person camera height.

Definition at line 40 of file ship.hpp.

◆ continuous_fire_timer

int Ship::continuous_fire_timer = 0

Timer controlling continuous fire.

Definition at line 56 of file ship.hpp.

◆ current_speed

float Ship::current_speed = 1.0f

Current forward speed.

Definition at line 28 of file ship.hpp.

◆ exploding

bool Ship::exploding = false

Whether the ship is currently exploding.

Definition at line 44 of file ship.hpp.

◆ explosion_timer

int Ship::explosion_timer = 0

Remaining explosion animation frames.

Definition at line 46 of file ship.hpp.

◆ fire_cooldown

int Ship::fire_cooldown = 0

Frames remaining before the next shot is allowed.

Definition at line 52 of file ship.hpp.

◆ lives

int Ship::lives = 5

Remaining lives.

Definition at line 48 of file ship.hpp.

◆ max_speed

float Ship::max_speed = 25.0f

Maximum controllable speed.

Definition at line 32 of file ship.hpp.

◆ min_speed

float Ship::min_speed = 0.1f

Minimum controllable speed.

Definition at line 30 of file ship.hpp.

◆ overheat_cooldown

int Ship::overheat_cooldown = 0

Frames remaining in the overheat cooldown.

Definition at line 60 of file ship.hpp.

◆ overheated

bool Ship::overheated = false

Whether firing is disabled by overheating.

Definition at line 58 of file ship.hpp.

◆ pitch_speed_multiplier

float Ship::pitch_speed_multiplier = 0.55f

Pitch rate relative to the yaw rate.

Definition at line 36 of file ship.hpp.

◆ position

glm::vec3 Ship::position {0.0f, 0.0f, 0.0f}

Current world-space position.

Definition at line 20 of file ship.hpp.

20{0.0f, 0.0f, 0.0f};

◆ prev_position

glm::vec3 Ship::prev_position {0.0f, 0.0f, 0.0f}

Position from the previous simulation step.

Definition at line 22 of file ship.hpp.

22{0.0f, 0.0f, 0.0f};

◆ rotation

glm::vec3 Ship::rotation {0.0f}

Euler rotation in degrees.

Definition at line 26 of file ship.hpp.

26{0.0f};

◆ score

int Ship::score = 0

Current score.

Definition at line 50 of file ship.hpp.

◆ turn_speed

float Ship::turn_speed = 140.0f

Yaw rate in degrees per second.

Definition at line 34 of file ship.hpp.

◆ velocity

glm::vec3 Ship::velocity {0.0f}

Current world-space velocity.

Definition at line 24 of file ship.hpp.

24{0.0f};

◆ visible

bool Ship::visible = true

Whether the ship is rendered.

Definition at line 42 of file ship.hpp.


The documentation for this class was generated from the following files: