|
|
@ -50,18 +50,30 @@ sf::Color GUI::color(Value val) { |
|
|
|
return VALUES[size_t(val)]; |
|
|
|
return VALUES[size_t(val)]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GUI::GUI() : $game_map(GAME_MAP_X, GAME_MAP_Y), |
|
|
|
GUI::GUI() : |
|
|
|
$canvas(VIEW_PORT_X * 2, VIEW_PORT_Y * 4), |
|
|
|
$game_map(GAME_MAP_X, GAME_MAP_Y), |
|
|
|
$window(sf::VideoMode(VIDEO_X,VIDEO_Y), "Roguish"), |
|
|
|
$window(sf::VideoMode(VIDEO_X,VIDEO_Y), "Roguish"), |
|
|
|
$screen(SCREEN_X, SCREEN_Y), |
|
|
|
$screen(SCREEN_X, SCREEN_Y), |
|
|
|
$map_screen(VIEW_PORT_X, VIEW_PORT_Y) |
|
|
|
$map_screen(0,0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
$font.loadFromFile("./assets/text.otf"); |
|
|
|
|
|
|
|
// calculate display size
|
|
|
|
|
|
|
|
sf::Glyph base_glyph = $font.getGlyph(L'█', MAP_FONT_SIZE, false); |
|
|
|
|
|
|
|
auto bounds = base_glyph.bounds; |
|
|
|
|
|
|
|
$view_port = { |
|
|
|
|
|
|
|
size_t(std::ceil((VIDEO_X - GAME_MAP_POS) / bounds.width)), |
|
|
|
|
|
|
|
size_t(std::ceil(VIDEO_Y / bounds.height)) |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// set canvas to best size
|
|
|
|
|
|
|
|
$canvas = Canvas($view_port.x * 2, $view_port.y * 4); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map_screen = Screen($view_port.x, $view_port.y); |
|
|
|
|
|
|
|
|
|
|
|
int res = $hit_buf.loadFromFile("./assets/hit.wav"); |
|
|
|
int res = $hit_buf.loadFromFile("./assets/hit.wav"); |
|
|
|
dbc::check(res, "failed to load hit.wav"); |
|
|
|
dbc::check(res, "failed to load hit.wav"); |
|
|
|
$hit_sound.setBuffer($hit_buf); |
|
|
|
$hit_sound.setBuffer($hit_buf); |
|
|
|
|
|
|
|
|
|
|
|
$font.loadFromFile("./assets/text.otf"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ui_text.setFont($font); |
|
|
|
$ui_text.setFont($font); |
|
|
|
$ui_text.setPosition(0,0); |
|
|
|
$ui_text.setPosition(0,0); |
|
|
|
$ui_text.setCharacterSize(UI_FONT_SIZE); |
|
|
|
$ui_text.setCharacterSize(UI_FONT_SIZE); |
|
|
@ -74,7 +86,7 @@ void GUI::create_renderer() { |
|
|
|
auto player = $world.get<Player>(); |
|
|
|
auto player = $world.get<Player>(); |
|
|
|
|
|
|
|
|
|
|
|
$map_view = Renderer([&] { |
|
|
|
$map_view = Renderer([&] { |
|
|
|
System::draw_map($world, $game_map, $canvas, VIEW_PORT_X, VIEW_PORT_Y); |
|
|
|
System::draw_map($world, $game_map, $canvas, $view_port.x, $view_port.y); |
|
|
|
return canvas($canvas); |
|
|
|
return canvas($canvas); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|