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
2
Makefile
2
Makefile
|
|
@ -60,7 +60,7 @@ clean:
|
||||||
meson compile --clean -C builddir
|
meson compile --clean -C builddir
|
||||||
|
|
||||||
debug_test: build
|
debug_test: build
|
||||||
gdb --nx -x .gdbinit --ex run --ex bt --ex q --args builddir/runtests -e "[lighting]"
|
gdb --nx -x .gdbinit --ex run --ex bt --ex q --args builddir/runtests -e
|
||||||
|
|
||||||
win_installer:
|
win_installer:
|
||||||
powershell 'start "C:\Program Files (x86)\solicus\InstallForge\bin\ifbuilderenvx86.exe" scripts\win_installer.ifp'
|
powershell 'start "C:\Program Files (x86)\solicus\InstallForge\bin\ifbuilderenvx86.exe" scripts\win_installer.ifp'
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
"RAT_KING": {
|
"RAT_KING": {
|
||||||
"components": [
|
"components": [
|
||||||
{"_type": "BossFight",
|
{"_type": "BossFight",
|
||||||
"background": "boss_fight_background",
|
"background": "test_background",
|
||||||
"stage": null,
|
"floor": "test_floor",
|
||||||
"weapon_sound": "Sword_Hit_2"
|
"weapon_sound": "Sword_Hit_2"
|
||||||
},
|
},
|
||||||
{"_type": "Combat", "hp": 20, "max_hp": 20, "damage": 20, "dead": false},
|
{"_type": "Combat", "hp": 20, "max_hp": 20, "damage": 20, "dead": false},
|
||||||
|
|
@ -16,15 +16,15 @@
|
||||||
"scale": 0.2,
|
"scale": 0.2,
|
||||||
"stationary": false
|
"stationary": false
|
||||||
},
|
},
|
||||||
{"_type": "Sprite", "name": "rat_king_boss", "width": 720, "height": 720, "scale": 0.8, "stationary": false},
|
{"_type": "Sprite", "name": "test_boss", "width": 720, "height": 720, "scale": 0.8, "stationary": false},
|
||||||
{"_type": "Sound", "attack": "Marmot_Scream_1", "death": "Creature_Death_1"}
|
{"_type": "Sound", "attack": "Marmot_Scream_1", "death": "Creature_Death_1"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"DEVILS_FINGERS": {
|
"DEVILS_FINGERS": {
|
||||||
"components": [
|
"components": [
|
||||||
{"_type": "BossFight",
|
{"_type": "BossFight",
|
||||||
"background": "devils_fingers_background",
|
"background": "test_background",
|
||||||
"stage": "devils_fingers_stage",
|
"floor": "test_floor",
|
||||||
"weapon_sound": "Sword_Hit_2"
|
"weapon_sound": "Sword_Hit_2"
|
||||||
},
|
},
|
||||||
{"_type": "Combat", "hp": 20, "max_hp": 20, "damage": 20, "dead": false},
|
{"_type": "Combat", "hp": 20, "max_hp": 20, "damage": 20, "dead": false},
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
"stationary": true
|
"stationary": true
|
||||||
},
|
},
|
||||||
{"_type": "Sprite",
|
{"_type": "Sprite",
|
||||||
"name": "devils_fingers_sprite",
|
"name": "test_boss",
|
||||||
"width": 720,
|
"width": 720,
|
||||||
"height": 720,
|
"height": 720,
|
||||||
"scale": 1.0
|
"scale": 1.0
|
||||||
|
|
|
||||||
BIN
assets/bossfights/test_background.png
Normal file
BIN
assets/bossfights/test_background.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
BIN
assets/bossfights/test_boss.png
Normal file
BIN
assets/bossfights/test_boss.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
assets/bossfights/test_floor.png
Normal file
BIN
assets/bossfights/test_floor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
BIN
assets/bossfights/test_player.png
Normal file
BIN
assets/bossfights/test_player.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
BIN
assets/bossfights/test_thirds.png
Normal file
BIN
assets/bossfights/test_thirds.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
|
|
@ -243,7 +243,32 @@
|
||||||
"peasant_girl_rear_view":
|
"peasant_girl_rear_view":
|
||||||
{"path": "assets/sprites/peasant_girl_rear_view_01.png",
|
{"path": "assets/sprites/peasant_girl_rear_view_01.png",
|
||||||
"frame_width": 400,
|
"frame_width": 400,
|
||||||
"frame_height": 543
|
"frame_height": 540
|
||||||
|
},
|
||||||
|
"test_background":
|
||||||
|
{"path": "assets/bossfights/test_background.png",
|
||||||
|
"frame_width": 1920,
|
||||||
|
"frame_height": 1080
|
||||||
|
},
|
||||||
|
"test_boss":
|
||||||
|
{"path": "assets/bossfights/test_boss.png",
|
||||||
|
"frame_width": 498,
|
||||||
|
"frame_height": 832
|
||||||
|
},
|
||||||
|
"test_floor":
|
||||||
|
{"path": "assets/bossfights/test_floor.png",
|
||||||
|
"frame_width": 1920,
|
||||||
|
"frame_height": 1080
|
||||||
|
},
|
||||||
|
"test_player":
|
||||||
|
{"path": "assets/bossfights/test_player.png",
|
||||||
|
"frame_width": 208,
|
||||||
|
"frame_height": 434
|
||||||
|
},
|
||||||
|
"test_thirds":
|
||||||
|
{"path": "assets/bossfights/test_thirds.png",
|
||||||
|
"frame_width": 1656,
|
||||||
|
"frame_height": 1080
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"worldgen": {
|
"worldgen": {
|
||||||
|
|
|
||||||
BIN
assets/sprites/peasant_girl_rear_view_01.png
Normal file
BIN
assets/sprites/peasant_girl_rear_view_01.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
42
boss/ui.cpp
42
boss/ui.cpp
|
|
@ -2,30 +2,58 @@
|
||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
|
|
||||||
namespace boss {
|
namespace boss {
|
||||||
UI::UI(shared_ptr<World> world, Entity boss_id)
|
using namespace guecs;
|
||||||
: $world(world), $boss_id(boss_id)
|
|
||||||
|
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() {
|
void UI::init() {
|
||||||
$gui.position(SCREEN_WIDTH-BOSS_VIEW_WIDTH,0, BOSS_VIEW_WIDTH, SCREEN_HEIGHT);
|
$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(
|
$gui.layout(
|
||||||
"[a1|b1|c1|d1|e1|f1]"
|
"[a1|boss1|boss2|boss3|e1|f1]"
|
||||||
"[a2|b2|c2|d2|e2|f2]"
|
"[a2|b2|c2|d2|e2|f2]"
|
||||||
"[a3|b3|c3|d3|e3|f3]"
|
"[floor2|b3|c3|d3|e3|f3]"
|
||||||
"[a4|b4|c4|d4|e4|f4]"
|
"[a4|b4|c4|d4|e4|f4]"
|
||||||
"[a5|b5|c5|d5|e5|f5]"
|
"[floor1|player1|player2|player3|e5|f5]"
|
||||||
"[a6|b6|c6|d6|e6|f6]"
|
"[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();
|
$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) {
|
void UI::render(sf::RenderWindow& window) {
|
||||||
$gui.render(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);
|
return $gui.mouse(x, y, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,19 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <SFML/Graphics/RenderWindow.hpp>
|
#include <SFML/Graphics/RenderWindow.hpp>
|
||||||
#include <guecs/ui.hpp>
|
#include <guecs/ui.hpp>
|
||||||
|
#include "textures.hpp"
|
||||||
|
|
||||||
namespace boss {
|
namespace boss {
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
using namespace DinkyECS;
|
using namespace DinkyECS;
|
||||||
|
using namespace textures;
|
||||||
|
|
||||||
struct UI {
|
struct UI {
|
||||||
shared_ptr<World> $world = nullptr;
|
shared_ptr<World> $world = nullptr;
|
||||||
Entity $boss_id = NONE;
|
Entity $boss_id = NONE;
|
||||||
|
SpriteTexture $boss_sprite;
|
||||||
|
SpriteTexture $player_sprite;
|
||||||
|
SpriteTexture $floor_sprite;
|
||||||
guecs::UI $gui;
|
guecs::UI $gui;
|
||||||
|
|
||||||
UI(shared_ptr<World> world, Entity boss_id);
|
UI(shared_ptr<World> world, Entity boss_id);
|
||||||
|
|
@ -18,6 +23,7 @@ namespace boss {
|
||||||
void init();
|
void init();
|
||||||
void render(sf::RenderWindow& window);
|
void render(sf::RenderWindow& window);
|
||||||
bool mouse(float x, float y, guecs::Modifiers mods);
|
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();
|
bool boss_dead();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ namespace components {
|
||||||
|
|
||||||
struct BossFight {
|
struct BossFight {
|
||||||
std::string background;
|
std::string background;
|
||||||
std::optional<std::string> stage;
|
std::optional<std::string> floor;
|
||||||
std::string weapon_sound;
|
std::string weapon_sound;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -147,7 +147,7 @@ namespace components {
|
||||||
using ComponentMap = std::unordered_map<std::string, ReflFuncSignature>;
|
using ComponentMap = std::unordered_map<std::string, ReflFuncSignature>;
|
||||||
|
|
||||||
ENROLL_COMPONENT(Tile, display, foreground, background);
|
ENROLL_COMPONENT(Tile, display, foreground, background);
|
||||||
ENROLL_COMPONENT(BossFight, background, stage, weapon_sound);
|
ENROLL_COMPONENT(BossFight, background, floor, weapon_sound);
|
||||||
ENROLL_COMPONENT(Sprite, name, width, height, scale);
|
ENROLL_COMPONENT(Sprite, name, width, height, scale);
|
||||||
ENROLL_COMPONENT(Curative, hp);
|
ENROLL_COMPONENT(Curative, hp);
|
||||||
ENROLL_COMPONENT(LightSource, strength, radius);
|
ENROLL_COMPONENT(LightSource, strength, radius);
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ TEST_CASE("make sure json_mods works", "[components]") {
|
||||||
if(comp_data["_type"] == "BossFight") {
|
if(comp_data["_type"] == "BossFight") {
|
||||||
auto comp = components::convert<components::BossFight>(comp_data);
|
auto comp = components::convert<components::BossFight>(comp_data);
|
||||||
// the boss fight for the rat king doesn't have a stage so false=optional
|
// the boss fight for the rat king doesn't have a stage so false=optional
|
||||||
REQUIRE(comp.stage == std::nullopt);
|
REQUIRE(comp.floor != std::nullopt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,11 +51,11 @@ TEST_CASE("make sure json_mods works", "[components]") {
|
||||||
components::configure_entity(world, rat_king, config["RAT_KING"]["components"]);
|
components::configure_entity(world, rat_king, config["RAT_KING"]["components"]);
|
||||||
|
|
||||||
auto boss = world.get<BossFight>(rat_king);
|
auto boss = world.get<BossFight>(rat_king);
|
||||||
REQUIRE(boss.stage == std::nullopt);
|
REQUIRE(boss.floor != std::nullopt);
|
||||||
|
|
||||||
// now load the other one for the other way optional is used
|
// now load the other one for the other way optional is used
|
||||||
auto devils_fingers = world.entity();
|
auto devils_fingers = world.entity();
|
||||||
components::configure_entity(world, devils_fingers, config["DEVILS_FINGERS"]["components"]);
|
components::configure_entity(world, devils_fingers, config["DEVILS_FINGERS"]["components"]);
|
||||||
auto boss2 = world.get<BossFight>(devils_fingers);
|
auto boss2 = world.get<BossFight>(devils_fingers);
|
||||||
REQUIRE(boss2.stage != std::nullopt);
|
REQUIRE(boss2.floor != std::nullopt);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue