Finally have the boss fight rendering into a render texture correctly. The 'flipped' problem was because I didn't call .display() in render.
This commit is contained in:
parent
82a38e5fa1
commit
740e1052fe
6 changed files with 17 additions and 11 deletions
|
|
@ -41,7 +41,6 @@ namespace components {
|
||||||
|
|
||||||
if(playing && current < frames) {
|
if(playing && current < frames) {
|
||||||
float tick = twitching();
|
float tick = twitching();
|
||||||
fmt::print("tick: {}\r", tick);
|
|
||||||
|
|
||||||
if(stationary) {
|
if(stationary) {
|
||||||
switch(motion) {
|
switch(motion) {
|
||||||
|
|
|
||||||
15
boss/ui.cpp
15
boss/ui.cpp
|
|
@ -8,8 +8,11 @@ namespace boss {
|
||||||
UI::UI(components::AnimatedScene& scene, Entity boss_id) :
|
UI::UI(components::AnimatedScene& scene, Entity boss_id) :
|
||||||
$boss_id(boss_id),
|
$boss_id(boss_id),
|
||||||
$combat_ui(true),
|
$combat_ui(true),
|
||||||
$arena(scene)
|
$arena(scene),
|
||||||
|
$view_texture({BOSS_VIEW_WIDTH, BOSS_VIEW_HEIGHT}),
|
||||||
|
$view_sprite($view_texture.getTexture())
|
||||||
{
|
{
|
||||||
|
$view_sprite.setPosition({BOSS_VIEW_X, BOSS_VIEW_Y});
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::init() {
|
void UI::init() {
|
||||||
|
|
@ -37,13 +40,15 @@ namespace boss {
|
||||||
void UI::render(sf::RenderWindow& window) {
|
void UI::render(sf::RenderWindow& window) {
|
||||||
$actions.render(window);
|
$actions.render(window);
|
||||||
$combat_ui.render(window);
|
$combat_ui.render(window);
|
||||||
$arena.render(window);
|
$arena.render($view_texture);
|
||||||
|
$view_texture.display();
|
||||||
|
window.draw($view_sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UI::mouse(float x, float y, Modifiers mods) {
|
bool UI::mouse(float x, float y, Modifiers mods) {
|
||||||
return $arena.mouse(x, y, mods)
|
// BUG: arena is getting the _window_ coordinates, not the rendertexture
|
||||||
|| $combat_ui.mouse(x, y, mods)
|
return $combat_ui.mouse(x, y, mods)
|
||||||
|| $actions.mouse(x, y, mods);
|
|| $actions.mouse(x, y, mods) || $arena.mouse(x, y, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::status(const std::wstring& msg) {
|
void UI::status(const std::wstring& msg) {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ namespace boss {
|
||||||
gui::CombatUI $combat_ui;
|
gui::CombatUI $combat_ui;
|
||||||
scene::Engine $arena;
|
scene::Engine $arena;
|
||||||
guecs::UI $actions;
|
guecs::UI $actions;
|
||||||
|
sf::RenderTexture $view_texture;
|
||||||
|
sf::Sprite $view_sprite;
|
||||||
|
|
||||||
UI(components::AnimatedScene &scene, DinkyECS::Entity boss_id);
|
UI(components::AnimatedScene &scene, DinkyECS::Entity boss_id);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ namespace scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::init() {
|
void Engine::init() {
|
||||||
$ui.position(SCREEN_WIDTH-BOSS_VIEW_WIDTH,0, BOSS_VIEW_WIDTH, SCREEN_HEIGHT);
|
$ui.position(0,0, BOSS_VIEW_WIDTH, BOSS_VIEW_HEIGHT);
|
||||||
$ui.set<guecs::Background>($ui.MAIN, {$ui.$parser, guecs::THEME.TRANSPARENT});
|
$ui.set<guecs::Background>($ui.MAIN, {$ui.$parser, guecs::THEME.TRANSPARENT});
|
||||||
auto& background = $ui.get<guecs::Background>($ui.MAIN);
|
auto& background = $ui.get<guecs::Background>($ui.MAIN);
|
||||||
background.set_sprite($scene.background, true);
|
background.set_sprite($scene.background, true);
|
||||||
|
|
@ -72,7 +72,7 @@ namespace scene {
|
||||||
return $ui.mouse(x, y, mods);
|
return $ui.mouse(x, y, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::render(sf::RenderWindow& window) {
|
void Engine::render(sf::RenderTarget& window) {
|
||||||
$ui.render(window);
|
$ui.render(window);
|
||||||
|
|
||||||
for(auto& fixture : $fixtures) {
|
for(auto& fixture : $fixtures) {
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ namespace scene {
|
||||||
Engine(components::AnimatedScene& scene);
|
Engine(components::AnimatedScene& scene);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void render(sf::RenderWindow& window);
|
void render(sf::RenderTarget& window);
|
||||||
bool mouse(float x, float y, guecs::Modifiers mods);
|
bool mouse(float x, float y, guecs::Modifiers mods);
|
||||||
|
|
||||||
sf::Vector2f position_sprite(textures::SpriteTexture& st, const std::string& cell_name, float scale_x, float scale_y, bool at_mid, float x_diff=0.0f, float y_diff=0.0f);
|
sf::Vector2f position_sprite(textures::SpriteTexture& st, const std::string& cell_name, float scale_x, float scale_y, bool at_mid, float x_diff=0.0f, float y_diff=0.0f);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[wrap-git]
|
[wrap-git]
|
||||||
directory=lel-guecs-0.6.0
|
directory=lel-guecs-0.7.0
|
||||||
url=https://git.learnjsthehardway.com/learn-code-the-hard-way/lel-guecs.git
|
url=https://git.zedshaw.games/games/lel-guecs.git
|
||||||
revision=HEAD
|
revision=HEAD
|
||||||
depth=1
|
depth=1
|
||||||
method=meson
|
method=meson
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue