First cut of pulling out the relevant parts of my original game to make a little framework.

This commit is contained in:
Zed A. Shaw 2026-03-22 10:37:45 -04:00
commit 6a0c9e8d46
177 changed files with 18197 additions and 0 deletions

43
tests/textures.cpp Normal file
View file

@ -0,0 +1,43 @@
#include <catch2/catch_test_macros.hpp>
#include <fmt/core.h>
#include <string>
#include "graphics/textures.hpp"
#include "constants.hpp"
#include "game/components.hpp"
using namespace fmt;
TEST_CASE("test texture management", "[textures]") {
components::init();
textures::init();
auto spider = textures::get_sprite("rat_with_sword");
REQUIRE(spider.sprite != nullptr);
REQUIRE(spider.texture != nullptr);
REQUIRE(spider.frame_size.x == TEXTURE_WIDTH);
REQUIRE(spider.frame_size.y == TEXTURE_HEIGHT);
auto image = textures::load_image("assets/sprites/rat_with_sword.png");
size_t floor_tile = textures::get_id("floor_tile");
size_t gray_stone = textures::get_id("door_plain");
auto floor_ptr = textures::get_surface(floor_tile);
REQUIRE(floor_ptr != nullptr);
auto gray_stone_ptr = textures::get_surface(gray_stone);
REQUIRE(gray_stone_ptr != nullptr);
auto& light = textures::get_ambient_light();
REQUIRE(light.size() > 0);
REQUIRE(light[floor_tile] == 0);
REQUIRE(light[gray_stone] > 0);
auto& tiles = textures::get_map_tile_set();
REQUIRE(tiles.size() > 0);
REQUIRE(tiles[floor_tile] > 0);
REQUIRE(tiles[gray_stone] > 0);
auto ceiling = textures::get_ceiling(floor_tile);
REQUIRE(ceiling != nullptr);
}