Map tiles are generating fine, and I can make a map, now to bring it into the game and see how it works.
This commit is contained in:
parent
5db3d1a306
commit
3b06105813
5 changed files with 33 additions and 40 deletions
|
@ -8,121 +8,121 @@
|
||||||
{
|
{
|
||||||
"centered": false,
|
"centered": false,
|
||||||
"display": 8284,
|
"display": 8284,
|
||||||
"x": 64,
|
"x": 32,
|
||||||
"y": 0
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": false,
|
"centered": false,
|
||||||
"display": 11590,
|
"display": 11590,
|
||||||
"x": 128,
|
"x": 64,
|
||||||
"y": 0
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": false,
|
"centered": false,
|
||||||
"display": 10899,
|
"display": 10899,
|
||||||
"x": 192,
|
"x": 96,
|
||||||
"y": 0
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": false,
|
"centered": false,
|
||||||
"display": 9256,
|
"display": 9256,
|
||||||
"x": 256,
|
"x": 128,
|
||||||
"y": 0
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": false,
|
"centered": false,
|
||||||
"display": 9608,
|
"display": 9608,
|
||||||
"x": 320,
|
"x": 160,
|
||||||
"y": 0
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": false,
|
"centered": false,
|
||||||
"display": 10747,
|
"display": 10747,
|
||||||
"x": 384,
|
"x": 192,
|
||||||
"y": 0
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": false,
|
"centered": false,
|
||||||
"display": 8285,
|
"display": 8285,
|
||||||
"x": 448,
|
"x": 224,
|
||||||
"y": 0
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": true,
|
"centered": true,
|
||||||
"display": 1003,
|
"display": 1003,
|
||||||
"x": 512,
|
"x": 256,
|
||||||
"y": 0
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": true,
|
"centered": true,
|
||||||
"display": 3848,
|
"display": 3848,
|
||||||
"x": 576,
|
"x": 288,
|
||||||
"y": 0
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": true,
|
"centered": true,
|
||||||
"display": 85,
|
"display": 85,
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 64
|
"y": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": true,
|
"centered": true,
|
||||||
"display": 8687,
|
"display": 8687,
|
||||||
"x": 64,
|
"x": 32,
|
||||||
"y": 64
|
"y": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": true,
|
"centered": true,
|
||||||
"display": 10949,
|
"display": 10949,
|
||||||
"x": 128,
|
"x": 64,
|
||||||
"y": 64
|
"y": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": true,
|
"centered": true,
|
||||||
"display": 8793,
|
"display": 8793,
|
||||||
"x": 192,
|
"x": 96,
|
||||||
"y": 64
|
"y": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": true,
|
"centered": true,
|
||||||
"display": 95,
|
"display": 95,
|
||||||
"x": 256,
|
"x": 128,
|
||||||
"y": 64
|
"y": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": true,
|
"centered": true,
|
||||||
"display": 1898,
|
"display": 1898,
|
||||||
"x": 320,
|
"x": 160,
|
||||||
"y": 64
|
"y": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": true,
|
"centered": true,
|
||||||
"display": 42586,
|
"display": 42586,
|
||||||
"x": 384,
|
"x": 192,
|
||||||
"y": 64
|
"y": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": true,
|
"centered": true,
|
||||||
"display": 2189,
|
"display": 2189,
|
||||||
"x": 448,
|
"x": 224,
|
||||||
"y": 64
|
"y": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": true,
|
"centered": true,
|
||||||
"display": 41981,
|
"display": 41981,
|
||||||
"x": 512,
|
"x": 256,
|
||||||
"y": 64
|
"y": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": true,
|
"centered": true,
|
||||||
"display": 2220,
|
"display": 2220,
|
||||||
"x": 576,
|
"x": 288,
|
||||||
"y": 64
|
"y": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"centered": true,
|
"centered": true,
|
||||||
"display": 1218,
|
"display": 1218,
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 128
|
"y": 64
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 4.6 KiB |
|
@ -15,6 +15,8 @@ constexpr const int RAY_VIEW_Y=0;
|
||||||
constexpr const int GLOW_LIMIT=220;
|
constexpr const int GLOW_LIMIT=220;
|
||||||
constexpr const int LIGHT_MULTIPLIER=2.5;
|
constexpr const int LIGHT_MULTIPLIER=2.5;
|
||||||
constexpr const float AIMED_AT_BRIGHTNESS=0.2f;
|
constexpr const float AIMED_AT_BRIGHTNESS=0.2f;
|
||||||
|
constexpr const int MAP_TILE_DIM=32;
|
||||||
|
constexpr const int ICONGEN_MAP_TILE_DIM=32;
|
||||||
|
|
||||||
constexpr const int BOSS_VIEW_WIDTH=1080;
|
constexpr const int BOSS_VIEW_WIDTH=1080;
|
||||||
constexpr const int BOSS_VIEW_HEIGHT=SCREEN_HEIGHT;
|
constexpr const int BOSS_VIEW_HEIGHT=SCREEN_HEIGHT;
|
||||||
|
|
|
@ -96,7 +96,7 @@ TEST_CASE("map image test", "[map-sprite]") {
|
||||||
auto &walls = level.map->tiles();
|
auto &walls = level.map->tiles();
|
||||||
auto &tile_set = textures::get_map_tile_set();
|
auto &tile_set = textures::get_map_tile_set();
|
||||||
|
|
||||||
sf::Vector2i size{64,64};
|
sf::Vector2i size{MAP_TILE_DIM,MAP_TILE_DIM};
|
||||||
matrix::dump("TILES?", walls);
|
matrix::dump("TILES?", walls);
|
||||||
|
|
||||||
std::unordered_map<wchar_t, sf::Vector2i> sprite_coord;
|
std::unordered_map<wchar_t, sf::Vector2i> sprite_coord;
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
constexpr const int TILE_COUNT=10;
|
constexpr const int TILE_COUNT=10;
|
||||||
constexpr const sf::Color DEFAULT_COLOR{255, 255, 255, 255};
|
constexpr const sf::Color DEFAULT_COLOR{255, 255, 255, 255};
|
||||||
constexpr const size_t DEFAULT_DIM=64;
|
|
||||||
using namespace nlohmann;
|
using namespace nlohmann;
|
||||||
|
|
||||||
using namespace shiterator;
|
using namespace shiterator;
|
||||||
|
@ -85,7 +84,6 @@ struct MapTileBuilder {
|
||||||
|
|
||||||
void run_real_textures(MapConfig &config) {
|
void run_real_textures(MapConfig &config) {
|
||||||
sf::Vector2u crop{$size.x * (unsigned int)config.it.width, ($size.y) * ((unsigned int)config.it.y + 1)};
|
sf::Vector2u crop{$size.x * (unsigned int)config.it.width, ($size.y) * ((unsigned int)config.it.y + 1)};
|
||||||
fmt::println("TEXTURE CROP: {},{}; size: {},{}", $size.x, $size.y, crop.x, crop.y);
|
|
||||||
$render = std::make_shared<sf::RenderTexture>(crop);
|
$render = std::make_shared<sf::RenderTexture>(crop);
|
||||||
$render->clear({0,0,0,0});
|
$render->clear({0,0,0,0});
|
||||||
|
|
||||||
|
@ -154,9 +152,6 @@ struct MapTileBuilder {
|
||||||
dbc::check($size.x - t_size.x >= 0, "font too big on x");
|
dbc::check($size.x - t_size.x >= 0, "font too big on x");
|
||||||
dbc::check($size.y - t_size.y >= 0, "font too big on y");
|
dbc::check($size.y - t_size.y >= 0, "font too big on y");
|
||||||
|
|
||||||
fmt::println("display: {}, bg: {},{},{},{}; fg: {},{},{},{}",
|
|
||||||
(int)display_char, bg.r, bg.g, bg.b, bg.a, fg.r, fg.g, fg.b, fg.a);
|
|
||||||
|
|
||||||
// draw the background first
|
// draw the background first
|
||||||
background.setFillColor(bg);
|
background.setFillColor(bg);
|
||||||
|
|
||||||
|
@ -223,20 +218,16 @@ void load_config(MapConfig& config, bool is_centered, std::string path, std::fun
|
||||||
if(data.contains("foreground")) {
|
if(data.contains("foreground")) {
|
||||||
auto fg_color = data["foreground"];
|
auto fg_color = data["foreground"];
|
||||||
sf::Color fg{fg_color[0], fg_color[1], fg_color[2]};
|
sf::Color fg{fg_color[0], fg_color[1], fg_color[2]};
|
||||||
fmt::println("TILE {}, display: {} has foreground: {},{},{}", key, (int)display, fg.r, fg.g, fg.b);
|
|
||||||
config.colors.insert_or_assign(display, fg);
|
config.colors.insert_or_assign(display, fg);
|
||||||
} else {
|
} else {
|
||||||
fmt::println("TILE {}, {} has DEFAULT COLOR", key, (int)display);
|
|
||||||
config.colors.insert_or_assign(display, DEFAULT_COLOR);
|
config.colors.insert_or_assign(display, DEFAULT_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.contains("background")) {
|
if(data.contains("background")) {
|
||||||
auto bg_color = data["background"];
|
auto bg_color = data["background"];
|
||||||
sf::Color bg{bg_color[0], bg_color[1], bg_color[2]};
|
sf::Color bg{bg_color[0], bg_color[1], bg_color[2]};
|
||||||
fmt::println("TILE {} display: {} has background: {},{},{}", key, (int)display, bg.r, bg.g, bg.b);
|
|
||||||
config.backgrounds.insert_or_assign(display, bg);
|
config.backgrounds.insert_or_assign(display, bg);
|
||||||
} else {
|
} else {
|
||||||
fmt::println("TILE {} display: {} has transparent background", key, (int)display);
|
|
||||||
sf::Color bg{0, 0, 0, 0};
|
sf::Color bg{0, 0, 0, 0};
|
||||||
config.backgrounds.insert_or_assign(display, bg);
|
config.backgrounds.insert_or_assign(display, bg);
|
||||||
}
|
}
|
||||||
|
@ -269,7 +260,7 @@ int main() {
|
||||||
load_config(config, true, "./assets/enemies.json", component_display);
|
load_config(config, true, "./assets/enemies.json", component_display);
|
||||||
|
|
||||||
fmt::println("-----------------------------------------");
|
fmt::println("-----------------------------------------");
|
||||||
MapTileBuilder builder(DEFAULT_DIM, DEFAULT_DIM);
|
MapTileBuilder builder(ICONGEN_MAP_TILE_DIM, ICONGEN_MAP_TILE_DIM);
|
||||||
builder.run(config);
|
builder.run(config);
|
||||||
|
|
||||||
builder.save_image("./assets/map_tiles.png");
|
builder.save_image("./assets/map_tiles.png");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue