Map now displays and works, just need to refine the colors and the compass directions.
This commit is contained in:
parent
dca38397e7
commit
75646619b3
8 changed files with 77 additions and 74 deletions
|
@ -8,121 +8,121 @@
|
|||
{
|
||||
"centered": false,
|
||||
"display": 8284,
|
||||
"x": 32,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"centered": false,
|
||||
"display": 11590,
|
||||
"x": 64,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"centered": false,
|
||||
"display": 10899,
|
||||
"x": 96,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"centered": false,
|
||||
"display": 9256,
|
||||
"display": 11590,
|
||||
"x": 128,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"centered": false,
|
||||
"display": 9608,
|
||||
"x": 160,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"centered": false,
|
||||
"display": 10747,
|
||||
"display": 10899,
|
||||
"x": 192,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"centered": false,
|
||||
"display": 9256,
|
||||
"x": 256,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"centered": false,
|
||||
"display": 9608,
|
||||
"x": 320,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"centered": false,
|
||||
"display": 10747,
|
||||
"x": 384,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"centered": false,
|
||||
"display": 8285,
|
||||
"x": 224,
|
||||
"x": 448,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"centered": true,
|
||||
"display": 1003,
|
||||
"x": 256,
|
||||
"x": 512,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"centered": true,
|
||||
"display": 3848,
|
||||
"x": 288,
|
||||
"x": 576,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"centered": true,
|
||||
"display": 85,
|
||||
"x": 0,
|
||||
"y": 32
|
||||
"y": 64
|
||||
},
|
||||
{
|
||||
"centered": true,
|
||||
"display": 8687,
|
||||
"x": 32,
|
||||
"y": 32
|
||||
"x": 64,
|
||||
"y": 64
|
||||
},
|
||||
{
|
||||
"centered": true,
|
||||
"display": 10949,
|
||||
"x": 64,
|
||||
"y": 32
|
||||
"x": 128,
|
||||
"y": 64
|
||||
},
|
||||
{
|
||||
"centered": true,
|
||||
"display": 8793,
|
||||
"x": 96,
|
||||
"y": 32
|
||||
"x": 192,
|
||||
"y": 64
|
||||
},
|
||||
{
|
||||
"centered": true,
|
||||
"display": 95,
|
||||
"x": 128,
|
||||
"y": 32
|
||||
"x": 256,
|
||||
"y": 64
|
||||
},
|
||||
{
|
||||
"centered": true,
|
||||
"display": 1898,
|
||||
"x": 160,
|
||||
"y": 32
|
||||
"x": 320,
|
||||
"y": 64
|
||||
},
|
||||
{
|
||||
"centered": true,
|
||||
"display": 42586,
|
||||
"x": 192,
|
||||
"y": 32
|
||||
"x": 384,
|
||||
"y": 64
|
||||
},
|
||||
{
|
||||
"centered": true,
|
||||
"display": 2189,
|
||||
"x": 224,
|
||||
"y": 32
|
||||
"x": 448,
|
||||
"y": 64
|
||||
},
|
||||
{
|
||||
"centered": true,
|
||||
"display": 41981,
|
||||
"x": 256,
|
||||
"y": 32
|
||||
"x": 512,
|
||||
"y": 64
|
||||
},
|
||||
{
|
||||
"centered": true,
|
||||
"display": 2220,
|
||||
"x": 288,
|
||||
"y": 32
|
||||
"x": 576,
|
||||
"y": 64
|
||||
},
|
||||
{
|
||||
"centered": true,
|
||||
"display": 1218,
|
||||
"x": 0,
|
||||
"y": 64
|
||||
"y": 128
|
||||
}
|
||||
]
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 9.6 KiB |
|
@ -15,8 +15,8 @@ constexpr const int RAY_VIEW_Y=0;
|
|||
constexpr const int GLOW_LIMIT=220;
|
||||
constexpr const int LIGHT_MULTIPLIER=2.5;
|
||||
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 MAP_TILE_DIM=64;
|
||||
constexpr const int ICONGEN_MAP_TILE_DIM=64;
|
||||
|
||||
constexpr const int BOSS_VIEW_WIDTH=1080;
|
||||
constexpr const int BOSS_VIEW_HEIGHT=SCREEN_HEIGHT;
|
||||
|
|
|
@ -347,7 +347,7 @@ namespace gui {
|
|||
if(!sound::playing("ambient_1")) sound::play("ambient_1", true);
|
||||
$debug_ui.debug();
|
||||
shaders::reload();
|
||||
$map_ui.save_map("map.txt", $main_ui.$compass_dir);
|
||||
$map_ui.save_map($main_ui.$compass_dir);
|
||||
break;
|
||||
case KEY::O:
|
||||
autowalking = true;
|
||||
|
|
|
@ -18,6 +18,9 @@ namespace gui {
|
|||
|
||||
MapViewUI::MapViewUI(GameLevel &level) :
|
||||
$level(level),
|
||||
$map_render(std::make_shared<sf::RenderTexture>()),
|
||||
$map_sprite($map_render->getTexture()),
|
||||
$map_tiles(matrix::make(12,11)),
|
||||
$paper(textures::get("full_screen_paper"))
|
||||
{
|
||||
}
|
||||
|
@ -27,49 +30,45 @@ namespace gui {
|
|||
}
|
||||
|
||||
void MapViewUI::init() {
|
||||
//auto top_right = overlay.entity("top_right");
|
||||
//auto cell = overlay.cell_for(top_right);
|
||||
$gui.position(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
$gui.layout(
|
||||
"[log_view| *%(200)map_grid | _ ]"
|
||||
);
|
||||
|
||||
auto grid = $gui.entity("map_grid");
|
||||
$gui.set<Textual>(grid,
|
||||
{L"Loading...", 65, {27, 26, 23, 150}, 10});
|
||||
|
||||
$log_to = $gui.entity("log_view");
|
||||
$gui.set<Textual>($log_to, {L"Welcome to the Game!", 25, {37, 36, 33}, 25});
|
||||
|
||||
$paper.sprite->setPosition({0, 0});
|
||||
|
||||
auto map_cell = $gui.cell_for("map_grid");
|
||||
$map_sprite.setPosition({(float)map_cell.x, (float)map_cell.y + 30});
|
||||
|
||||
$gui.init();
|
||||
}
|
||||
|
||||
void MapViewUI::render(sf::RenderWindow &window, int compass_dir) {
|
||||
void MapViewUI::save_map(int compass_dir) {
|
||||
(void)compass_dir;
|
||||
// confirm we get two different maps
|
||||
auto out_img = $map_render->getTexture().copyToImage();
|
||||
bool worked = out_img.saveToFile("tmp/map_render.png");
|
||||
dbc::check(worked, "failed to render map");
|
||||
}
|
||||
|
||||
|
||||
void MapViewUI::render(sf::RenderWindow &window, int compass_dir) {
|
||||
window.draw(*$paper.sprite);
|
||||
|
||||
auto grid = $gui.entity("map_grid");
|
||||
// System::draw_map
|
||||
auto& map_text = $gui.get<Textual>(grid);
|
||||
map_text.update(L"MAP BROKEN");
|
||||
System::draw_map($level, $map_tiles, $entity_map, compass_dir);
|
||||
|
||||
System::render_map($map_tiles, $entity_map, *$map_render);
|
||||
|
||||
$map_sprite.setTexture($map_render->getTexture(), true);
|
||||
window.draw($map_sprite);
|
||||
|
||||
$gui.render(window);
|
||||
// $gui.debug_layout(window);
|
||||
}
|
||||
|
||||
void MapViewUI::save_map(const std::string& outfile, int compass_dir) {
|
||||
(void)compass_dir;
|
||||
std::wstring map_out = L"I'M BROKEN";
|
||||
|
||||
std::wofstream out(outfile, std::ios::binary);
|
||||
std::locale loc(std::locale::classic(), new std::codecvt_utf8<wchar_t>);
|
||||
out.imbue(loc);
|
||||
|
||||
out << map_out;
|
||||
dbc::check(out.good(), "failed to write map file");
|
||||
}
|
||||
|
||||
void MapViewUI::update() {
|
||||
if(auto text = $gui.get_if<Textual>($log_to)) {
|
||||
//BUG: I'm calling this what it is, fix it
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include "levelmanager.hpp"
|
||||
#include "textures.hpp"
|
||||
#include "matrix.hpp"
|
||||
#include <guecs/ui.hpp>
|
||||
#include <string>
|
||||
|
||||
|
@ -8,10 +9,14 @@ namespace gui {
|
|||
class MapViewUI {
|
||||
public:
|
||||
guecs::UI $gui;
|
||||
GameLevel $level;
|
||||
DinkyECS::Entity $log_to;
|
||||
textures::SpriteTexture $paper;
|
||||
EntityGrid $entity_map;
|
||||
std::deque<std::wstring> $messages;
|
||||
GameLevel $level;
|
||||
std::shared_ptr<sf::RenderTexture> $map_render;
|
||||
sf::Sprite $map_sprite;
|
||||
matrix::Matrix $map_tiles;
|
||||
textures::SpriteTexture $paper;
|
||||
|
||||
MapViewUI(GameLevel &level);
|
||||
void init();
|
||||
|
@ -19,6 +24,6 @@ namespace gui {
|
|||
void update_level(GameLevel &level);
|
||||
void log(std::wstring msg);
|
||||
void update();
|
||||
void save_map(const std::string& outfile, int compass_dir);
|
||||
void save_map(int compass_dir);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -101,7 +101,6 @@ TEST_CASE("map image test", "[map-sprite]") {
|
|||
player_pos.location.y = it.y;
|
||||
|
||||
System::draw_map(level, map_tiles, entity_map, 2);
|
||||
// on level start make one render texture with the base map
|
||||
System::render_map(map_tiles, entity_map, *render);
|
||||
|
||||
#ifdef TEST_RENDER
|
||||
|
|
|
@ -83,6 +83,7 @@ struct MapTileBuilder {
|
|||
}
|
||||
|
||||
void run_real_textures(MapConfig &config) {
|
||||
textures::init();
|
||||
sf::Vector2u crop{$size.x * (unsigned int)config.it.width, ($size.y) * ((unsigned int)config.it.y + 1)};
|
||||
$render = std::make_shared<sf::RenderTexture>(crop);
|
||||
$render->clear({0,0,0,0});
|
||||
|
@ -248,7 +249,6 @@ json& component_display(json& val) {
|
|||
}
|
||||
|
||||
int main() {
|
||||
textures::init();
|
||||
MapConfig config;
|
||||
|
||||
load_config(config, false, "./assets/tiles.json", [](json& val) -> json& {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue