thread stop clean up

This commit is contained in:
2025-12-01 11:56:43 -05:00
parent 17663a1f75
commit ee5cb71560
3 changed files with 23 additions and 21 deletions

View File

@@ -4,6 +4,7 @@
#include <random>
#include <raylib.h>
#include "raymath.h"
#include "rng.h"
#include "spawner.h"
#include "types.h"
@@ -21,13 +22,23 @@ float level_bottom = level_height + padding;
Rectangle walls[] = {};
Player player;
float player_width = 50;
Player player = {
{
.x = level_width / 2 - player_width / 2,
.y = level_height / 2 - player_width / 2,
.width = player_width,
.height = player_width,
},
3,
-10,
};
auto player_speed = 5.0f;
auto player_invulnerability = 1.0f;
uint32_t score;
Tear tears[100] = {};
std::array<Tear, 100> tears;
float tear_speed = 10;
float tear_range = 300;
float tear_radius = 10.0f;
@@ -127,7 +138,7 @@ struct ItemSpawner final : Spawner<Item, 100> {
}
void spawn() override {
const auto item_type = static_cast<ItemType>(Rng::generate(ItemType::ITEM_TYPE_COUNT));
const auto item_type = static_cast<ItemType>(Rng::generate(ITEM_TYPE_COUNT));
const auto x = Rng::generate(static_cast<int>(level_left), static_cast<int>(level_right));
const auto y = Rng::generate(static_cast<int>(level_top), static_cast<int>(level_bottom));
@@ -206,13 +217,6 @@ int main() {
enemy_spawner.start();
item_spawner.start();
player.width = 50;
player.height = 50;
player.x = level_width / 2 - player.width / 2;
player.y = level_height / 2 - player.height / 2;
player.lives = 3;
player.last_hit = -10;
std::string score_text_buffer;
score_text_buffer.reserve(64);
@@ -335,7 +339,8 @@ int main() {
const int text_left = static_cast<int>(level_left) + 10;
DrawRectangle(level_left, static_cast<int>(level_height) - 110, 200, 110, {130, 130, 130, 100});
DrawRectangle(static_cast<int>(level_left), static_cast<int>(level_height) - 110, 200, 110,
{130, 130, 130, 100});
std::format_to(std::back_inserter(score_text_buffer), "Score: {}", score);
DrawText(score_text_buffer.c_str(), text_left, static_cast<int>(level_height) - 100, 20, BLACK);