diff --git a/assets/animations.json b/assets/animations.json index 233bf87..f44eaeb 100644 --- a/assets/animations.json +++ b/assets/animations.json @@ -142,7 +142,7 @@ "speed": 0.02, "stationary": true }, - "torch_crappy": { + "torch_fixture": { "_type": "Animation", "easing": 0, "ease_rate": 0.5, diff --git a/assets/bosses.json b/assets/bosses.json index 4672d0b..70b40e1 100644 --- a/assets/bosses.json +++ b/assets/bosses.json @@ -18,10 +18,8 @@ "sprite": "rat_king_boss" }, "fixtures": [ - {"name": "torch_crappy", "scale": 0.8, "cell": "torch1"}, - {"name": "torch_crappy", "scale": 0.8, "cell": "torch2"}, - {"name": "rat_with_sword", "scale": 0.8, "cell": "boss13"}, - {"name": "rat_with_sword", "scale": 0.8, "cell": "boss16"} + {"name": "torch_fixture", "scale_x": 0.5, "scale_y": 0.5, "cell": "torch1", "x": 66, "y": -10}, + {"name": "torch_fixture", "scale_x": -0.5, "scale_y": 0.5, "cell": "torch2", "x": 130, "y": -10} ] }, {"_type": "Combat", "hp": 20, "max_hp": 20, "damage": 20, "dead": false}, diff --git a/assets/config.json b/assets/config.json index ac70ced..195ec1f 100644 --- a/assets/config.json +++ b/assets/config.json @@ -80,6 +80,11 @@ "frame_width": 256, "frame_height": 256 }, + "torch_fixture": + {"path": "assets/fixtures/torch_fixture.png", + "frame_width": 256, + "frame_height": 256 + }, "torch_crappy": {"path": "assets/items/torch_crappy.png", "frame_width": 256, diff --git a/assets/fixtures/torch_fixture.png b/assets/fixtures/torch_fixture.png new file mode 100644 index 0000000..472941a Binary files /dev/null and b/assets/fixtures/torch_fixture.png differ diff --git a/boss/ui.cpp b/boss/ui.cpp index f653ac5..7a6ccee 100644 --- a/boss/ui.cpp +++ b/boss/ui.cpp @@ -6,6 +6,8 @@ #include #include "sound.hpp" +const bool DEBUG=false; + namespace boss { using namespace guecs; @@ -35,10 +37,13 @@ namespace boss { st.sprite = std::make_shared(*st.texture); auto anim = animation::load(name); - float scale = fixture["scale"]; + float scale_x = fixture["scale_x"]; + float scale_y = fixture["scale_y"]; std::string cell = fixture["cell"]; + float x = fixture["x"]; + float y = fixture["y"]; - $fixtures.emplace_back(st, anim, cell, scale); + $fixtures.emplace_back(st, anim, cell, scale_x, scale_y, x, y); } } @@ -61,11 +66,12 @@ namespace boss { move_player($scene.player["start_pos"]); if($scene.floor) { - position_sprite($floor_sprite, $scene.floor_pos, 1.0, false); + position_sprite($floor_sprite, $scene.floor_pos, 1.0f, 1.0f, false); } for(auto& fixture : $fixtures) { - position_sprite(fixture.st, fixture.cell, fixture.scale, false); + position_sprite(fixture.st, fixture.cell, + fixture.scale_x, fixture.scale_y, false, fixture.x, fixture.y); } $arena.init(); @@ -89,13 +95,13 @@ namespace boss { $combat_ui.init(cell.x, cell.y, cell.w, cell.h); } - void UI::position_sprite(textures::SpriteTexture& st, const std::string& cell_name, float scale, bool at_mid) { + void UI::position_sprite(textures::SpriteTexture& st, const std::string& cell_name, float scale_x, float scale_y, bool at_mid, float x_diff, float y_diff) { auto& cell = $arena.cell_for(cell_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}); + st.sprite->setPosition({x + x_diff, y + y_diff}); + st.sprite->setScale({scale_x, scale_y}); } void UI::render(sf::RenderWindow& window) { @@ -114,6 +120,8 @@ namespace boss { window.draw(*$boss_sprite.sprite); window.draw(*$player_sprite.sprite); + + if(DEBUG) $arena.debug_layout(window); } bool UI::mouse(float x, float y, Modifiers mods) { @@ -127,14 +135,16 @@ namespace boss { } void UI::move_boss(const std::string& cell_name) { - position_sprite($boss_sprite, cell_name, $scene.boss["scale"], $scene.boss["mid_cell"]); + float scale = $scene.boss["scale"]; + position_sprite($boss_sprite, cell_name, scale, scale, $scene.boss["mid_cell"]); auto& cell = $arena.cell_for(cell_name); $boss_pos = {float(cell.mid_x), float(cell.mid_y)}; } void UI::move_player(const std::string& cell_name) { - position_sprite($player_sprite, cell_name, $scene.player["scale"], $scene.player["mid_cell"]); + float scale = $scene.player["scale"]; + position_sprite($player_sprite, cell_name, scale, scale, $scene.player["mid_cell"]); } void UI::play_animations(sf::RenderWindow& window) { diff --git a/boss/ui.hpp b/boss/ui.hpp index 02d8584..2084077 100644 --- a/boss/ui.hpp +++ b/boss/ui.hpp @@ -11,7 +11,11 @@ struct AnimatedFixture { textures::SpriteTexture st; components::Animation anim; std::string cell; - float scale; + float scale_x; + float scale_y; + float x; + float y; + bool at_mid=false; }; namespace boss { @@ -39,7 +43,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& cell_name, float scale, bool at_mid=false); + void 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); void status(const std::wstring& msg); void move_boss(const std::string& cell_name); void move_player(const std::string& cell_name); diff --git a/scripts/build_assets.ps1 b/scripts/build_assets.ps1 index 66d7009..66c1c07 100644 --- a/scripts/build_assets.ps1 +++ b/scripts/build_assets.ps1 @@ -30,7 +30,9 @@ function Build-Images { # Build-Images -Source "Items" -pixel_count 2 # Build-Images -Source "Animations" -pixel_count 6 # Build-Images -Source "Hands" -pixel_count 6 -Build-Images -Source "Boss2" -pixel_count 4 +# Build-Images -Source "Boss2" -pixel_count 4 +Build-Images -Source "Fixtures" -pixel_count 24 + #magick montage -tile 3x1 -geometry +0+0 -background transparent .\assets\hands\female_hand_*.png .\assets\hands\female_hand.png