Fixed the map so that it shows directional arrows instead of a compass.
This commit is contained in:
parent
c7c48658bd
commit
e6a8a8b338
11 changed files with 35 additions and 27 deletions
|
@ -303,5 +303,15 @@
|
|||
},
|
||||
"graphics": {
|
||||
"smooth_textures": false
|
||||
},
|
||||
"compass": {
|
||||
"N": 65514,
|
||||
"NE": 8663,
|
||||
"E": 8594,
|
||||
"SE": 8600,
|
||||
"S": 65516,
|
||||
"SW": 8665,
|
||||
"W": 8592,
|
||||
"NW": 8598
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <string>
|
||||
#include "color.hpp"
|
||||
#include <array>
|
||||
|
||||
constexpr const int TEXTURE_WIDTH=256;
|
||||
constexpr const int TEXTURE_HEIGHT=256;
|
||||
|
@ -72,3 +73,8 @@ constexpr wchar_t BG_TILE = L'█';
|
|||
constexpr wchar_t UI_BASE_CHAR = L'█';
|
||||
constexpr int BG_BOX_OFFSET=5;
|
||||
constexpr const char *FONT_FILE_NAME="./assets/text.otf";
|
||||
|
||||
|
||||
constexpr std::array<std::wstring, 8> COMPASS{
|
||||
// L"E", L"SE", L"S", L"SW", L"W", L"NW", L"N", L"NE"
|
||||
L"\u2192", L"\u2198", L"\uffec", L"\u21d9", L"\u2190", L"\u2196", L"\uffea", L"\u21d7" };
|
||||
|
|
|
@ -313,9 +313,9 @@ namespace gui {
|
|||
$combat_ui.render($window);
|
||||
|
||||
if($map_open) {
|
||||
$map_ui.render($window, $main_ui.$camera.aimed_at());
|
||||
$map_ui.render($window, $main_ui.$compass_dir);
|
||||
} else {
|
||||
$mini_map.render($window, $main_ui.$camera.aimed_at());
|
||||
$mini_map.render($window, $main_ui.$compass_dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "components.hpp"
|
||||
#include "easings.hpp"
|
||||
#include <fmt/xchar.h>
|
||||
#include "constants.hpp"
|
||||
|
||||
namespace gui {
|
||||
using namespace components;
|
||||
|
@ -27,8 +28,6 @@ namespace gui {
|
|||
$rayview.set_position(RAY_VIEW_X, RAY_VIEW_Y);
|
||||
$rayview.position_camera(player.x + 0.5, player.y + 0.5);
|
||||
|
||||
$overlay_ui.show_text("left", $compass[$compass_dir]);
|
||||
|
||||
auto st = textures::get("down_the_well");
|
||||
auto bounds = st.sprite->getLocalBounds();
|
||||
st.sprite->setPosition({RAY_VIEW_X + bounds.size.x / 2,
|
||||
|
@ -95,8 +94,7 @@ namespace gui {
|
|||
|
||||
void MainUI::plan_rotate(int dir) {
|
||||
// -1 is left, 1 is right
|
||||
$compass_dir = ($compass_dir + dir) % $compass.size();
|
||||
$overlay_ui.show_text("left", $compass[$compass_dir]);
|
||||
$compass_dir = ($compass_dir + dir) % COMPASS.size();
|
||||
$camera.plan_rotate(dir);
|
||||
}
|
||||
|
||||
|
@ -122,7 +120,6 @@ namespace gui {
|
|||
$rayview.position_camera(player.x + 0.5, player.y + 0.5);
|
||||
|
||||
$compass_dir = 0;
|
||||
$overlay_ui.show_text("left", $compass[$compass_dir]);
|
||||
|
||||
dirty();
|
||||
}
|
||||
|
|
|
@ -15,9 +15,6 @@ namespace gui {
|
|||
class MainUI {
|
||||
public:
|
||||
int $compass_dir = 0;
|
||||
std::array<std::wstring, 8> $compass{
|
||||
L"E", L"SE", L"S", L"SW", L"W", L"NW", L"N", L"NE"
|
||||
};
|
||||
bool $show_level = false;
|
||||
bool $needs_render = true;
|
||||
sf::Clock $clock;
|
||||
|
|
|
@ -44,13 +44,13 @@ namespace gui {
|
|||
$gui.init();
|
||||
}
|
||||
|
||||
void MapViewUI::render(sf::RenderWindow &window, Point aim) {
|
||||
void MapViewUI::render(sf::RenderWindow &window, int compass_dir) {
|
||||
window.draw(*$paper.sprite);
|
||||
|
||||
auto grid = $gui.entity("map_grid");
|
||||
auto status = $gui.entity("status");
|
||||
|
||||
std::wstring map_out = System::draw_map($level, 23, 9, aim);
|
||||
std::wstring map_out = System::draw_map($level, 23, 9, compass_dir);
|
||||
|
||||
auto& map_text = $gui.get<guecs::Textual>(grid);
|
||||
map_text.update(map_out);
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace gui {
|
|||
|
||||
MapViewUI(GameLevel &level);
|
||||
void init();
|
||||
void render(sf::RenderWindow &window, Point aim);
|
||||
void render(sf::RenderWindow &window, int compass_dir);
|
||||
void update_level(GameLevel &level);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ namespace gui {
|
|||
$map_grid.init(cell, $font);
|
||||
}
|
||||
|
||||
void MiniMapUI::render(sf::RenderWindow &window, Point aim) {
|
||||
std::wstring map_out = System::draw_map($level, 5, 3, aim);
|
||||
void MiniMapUI::render(sf::RenderWindow &window, int compass_dir) {
|
||||
std::wstring map_out = System::draw_map($level, 5, 3, compass_dir);
|
||||
$map_grid.update(map_out);
|
||||
window.draw(*$map_grid.text);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace gui {
|
|||
|
||||
MiniMapUI(GameLevel &level);
|
||||
void init(guecs::UI& overlay);
|
||||
void render(sf::RenderWindow &window, Point aim);
|
||||
void render(sf::RenderWindow &window, int compass_dir);
|
||||
void update_level(GameLevel &level);
|
||||
};
|
||||
}
|
||||
|
|
18
systems.cpp
18
systems.cpp
|
@ -337,7 +337,7 @@ void System::plan_motion(DinkyECS::World& world, Point move_to) {
|
|||
* This one is called inside the MapViewUI very often so
|
||||
* just avoid GameMap unlike the others.
|
||||
*/
|
||||
std::wstring System::draw_map(GameLevel level, size_t view_x, size_t view_y, Point aim) {
|
||||
std::wstring System::draw_map(GameLevel level, size_t view_x, size_t view_y, int compass_dir) {
|
||||
DinkyECS::World &world = *level.world;
|
||||
Map &map = *level.map;
|
||||
|
||||
|
@ -361,19 +361,17 @@ std::wstring System::draw_map(GameLevel level, size_t view_x, size_t view_y, Poi
|
|||
}
|
||||
|
||||
|
||||
if(aim.x >= cam_orig.x && aim.x <= cam_orig.x + view_x
|
||||
&& aim.y >= cam_orig.y && aim.y <= cam_orig.y + view_y)
|
||||
{
|
||||
Point aim_at = map.map_to_camera(aim, cam_orig);
|
||||
grid[aim_at.y][aim_at.x] = '*';
|
||||
}
|
||||
|
||||
// then get the enemy/item/device tiles and fill those in
|
||||
world.query<Position, Tile>([&](auto, auto &pos, auto &entity_glyph) {
|
||||
world.query<Position, Tile>([&](auto ent, auto &pos, auto &entity_glyph) {
|
||||
if(pos.location.x >= cam_orig.x && pos.location.x <= cam_orig.x + view_x
|
||||
&& pos.location.y >= cam_orig.y && pos.location.y <= cam_orig.y + view_y) {
|
||||
Point view_pos = map.map_to_camera(pos.location, cam_orig);
|
||||
grid[view_pos.y][view_pos.x] = entity_glyph.display;
|
||||
|
||||
if(ent == level.player) {
|
||||
grid[view_pos.y][view_pos.x] = COMPASS[compass_dir][0];
|
||||
} else {
|
||||
grid[view_pos.y][view_pos.x] = entity_glyph.display;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace System {
|
|||
void init_positions(DinkyECS::World &world, SpatialMap &collider);
|
||||
void device(DinkyECS::World &world, DinkyECS::Entity actor, DinkyECS::Entity item);
|
||||
void plan_motion(DinkyECS::World& world, Point move_to);
|
||||
std::wstring draw_map(GameLevel level, size_t view_x, size_t view_y, Point aim);
|
||||
std::wstring draw_map(GameLevel level, size_t view_x, size_t view_y, int compass_dir);
|
||||
|
||||
void enemy_ai(GameLevel &level);
|
||||
void combat(GameLevel &level);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue