#include "level.hpp" #include "game/components.hpp" #include namespace trb::game { components::wall_definition generate_random_wall() { static std::mt19937 engine{std::random_device{}()}; std::uniform_int_distribution count_dist(0, 4); std::uniform_int_distribution binary_dist(0, 1); auto def = components::wall_definition{ .wall_count = count_dist(engine), .type = static_cast(binary_dist(engine)), }; for (std::size_t i = 0; i < def.wall_count; ++i) { def.heights[i] = static_cast(binary_dist(engine)); } return def; } void level::create_wall_at(glm::uvec2 tile) { const auto wall_entity = entities.create(); entities.emplace(wall_entity, components::tile_position{tile}); entities.emplace(wall_entity, generate_random_wall()); } level::level() { // for (int x = 0; x < 22; x++) { // for (int y = 0; y < 16; y++) { create_wall_at({0, 0}); create_wall_at({11, 8}); //} //} } entt::basic_registry *level::get_entities() { return &entities; } glm::uvec2 level::get_bounds() const noexcept { return {WIDTH, HEIGHT}; } } // namespace trb::game