New bossfight layout with fake 'paper cutouts' to work out how the UI would work.
This commit is contained in:
parent
a4fdfb779f
commit
d398b042a7
13 changed files with 79 additions and 20 deletions
42
boss/ui.cpp
42
boss/ui.cpp
|
|
@ -2,30 +2,58 @@
|
|||
#include "constants.hpp"
|
||||
|
||||
namespace boss {
|
||||
UI::UI(shared_ptr<World> world, Entity boss_id)
|
||||
: $world(world), $boss_id(boss_id)
|
||||
using namespace guecs;
|
||||
|
||||
UI::UI(shared_ptr<World> world, Entity boss_id) :
|
||||
$world(world),
|
||||
$boss_id(boss_id),
|
||||
$boss_sprite(textures::get_sprite("test_boss")),
|
||||
$player_sprite(textures::get_sprite("test_player")),
|
||||
$floor_sprite(textures::get_sprite("test_floor"))
|
||||
{
|
||||
}
|
||||
|
||||
void UI::init() {
|
||||
$gui.position(SCREEN_WIDTH-BOSS_VIEW_WIDTH,0, BOSS_VIEW_WIDTH, SCREEN_HEIGHT);
|
||||
$gui.set<Background>($gui.MAIN, {$gui.$parser, THEME.DARK_MID});
|
||||
auto& background = $gui.get<Background>($gui.MAIN);
|
||||
background.set_sprite("test_background", true);
|
||||
|
||||
$gui.layout(
|
||||
"[a1|b1|c1|d1|e1|f1]"
|
||||
"[a1|boss1|boss2|boss3|e1|f1]"
|
||||
"[a2|b2|c2|d2|e2|f2]"
|
||||
"[a3|b3|c3|d3|e3|f3]"
|
||||
"[floor2|b3|c3|d3|e3|f3]"
|
||||
"[a4|b4|c4|d4|e4|f4]"
|
||||
"[a5|b5|c5|d5|e5|f5]"
|
||||
"[floor1|player1|player2|player3|e5|f5]"
|
||||
"[a6|b6|c6|d6|e6|f6]"
|
||||
);
|
||||
|
||||
|
||||
position_sprite($boss_sprite, "boss2", 0.4, true);
|
||||
position_sprite($player_sprite, "player1", 0.5, true);
|
||||
position_sprite($floor_sprite, "floor2", 1.0, false);
|
||||
|
||||
$gui.init();
|
||||
}
|
||||
|
||||
void UI::position_sprite(textures::SpriteTexture& st, const std::string& name, float scale, bool at_mid) {
|
||||
auto& cell = $gui.cell_for(name);
|
||||
float x = float(at_mid ? cell.mid_x : cell.x);
|
||||
float y = float(at_mid ? cell.mid_y : cell.y);
|
||||
|
||||
st.sprite->setPosition({x, y});
|
||||
st.sprite->setScale({scale, scale});
|
||||
}
|
||||
|
||||
void UI::render(sf::RenderWindow& window) {
|
||||
$gui.render(window);
|
||||
$gui.debug_layout(window);
|
||||
window.draw(*$floor_sprite.sprite);
|
||||
window.draw(*$boss_sprite.sprite);
|
||||
window.draw(*$player_sprite.sprite);
|
||||
// $gui.debug_layout(window);
|
||||
}
|
||||
|
||||
bool UI::mouse(float x, float y, guecs::Modifiers mods) {
|
||||
bool UI::mouse(float x, float y, Modifiers mods) {
|
||||
return $gui.mouse(x, y, mods);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,19 @@
|
|||
#include <memory>
|
||||
#include <SFML/Graphics/RenderWindow.hpp>
|
||||
#include <guecs/ui.hpp>
|
||||
#include "textures.hpp"
|
||||
|
||||
namespace boss {
|
||||
using std::shared_ptr;
|
||||
using namespace DinkyECS;
|
||||
using namespace textures;
|
||||
|
||||
struct UI {
|
||||
shared_ptr<World> $world = nullptr;
|
||||
Entity $boss_id = NONE;
|
||||
SpriteTexture $boss_sprite;
|
||||
SpriteTexture $player_sprite;
|
||||
SpriteTexture $floor_sprite;
|
||||
guecs::UI $gui;
|
||||
|
||||
UI(shared_ptr<World> world, Entity boss_id);
|
||||
|
|
@ -18,6 +23,7 @@ namespace boss {
|
|||
void init();
|
||||
void render(sf::RenderWindow& window);
|
||||
bool mouse(float x, float y, guecs::Modifiers mods);
|
||||
void position_sprite(SpriteTexture& st, const std::string& name, float scale, bool at_mid=false);
|
||||
bool boss_dead();
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue