From 387d1a5bf599c7997135b6ad0e2a43bf22582f1a Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Mon, 20 Oct 2025 00:29:12 -0400 Subject: [PATCH] Now have the ability to place animated fixtures anywhere and to flip them. --- assets/animations.json | 2 +- assets/bosses.json | 6 ++---- assets/config.json | 5 +++++ assets/fixtures/torch_fixture.png | Bin 0 -> 4451 bytes boss/ui.cpp | 28 +++++++++++++++++++--------- boss/ui.hpp | 8 ++++++-- scripts/build_assets.ps1 | 4 +++- 7 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 assets/fixtures/torch_fixture.png 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 0000000000000000000000000000000000000000..472941ac470d6a6ea55c55441e71a110d20d48f9 GIT binary patch literal 4451 zcmZ`-2{@E%8~(^rA!)OO>~gXUVeCo@*`l&U$e=SZOtvv2ODHYk(6MD1AxpAmkijS- z%MfE^ovG|Jjco`s=AUzQoImHk{`s!C-ud3|dfxYb@ArQ0=l$m4B`XuY{UZAT0N^t- zHMRu+Hr7uzU@sS|arQ6rVl@&FQ(H>_K*<3>WDEdovbrK?0U!tj0P}7Dppymwg7D0G z8$H$oE_ZViV}SYBmD5=Gl-08jZt55S0OD`|`m(h^uUuwzatE4Op68z1e`Jq{Y@%+_ z1pqjxY-W7+O2`Ohyw}g!(XM%Eq8j})_-fLd=MSIWI5Ydg=>gw-pSR>6KPrpqdz60L z+ge}c-dffGdE17$VA{$PZ2Cb~My8eB`SCF$5y=<#?Mh4{#QfA&CWS>w1u{zLW z<7J3m>~D@QD9 zl`zqAasi6v#oS=ayu1nk?R$YpNInoEd{_Xf1}mM7#)UaHm6L`NnVIW?ZC#RpTfvP# z^#wK(qJvdFwU<-7s0EZC>Acg7tR;U_ww-XT8a)mTy#2HG2$RIZyMmm*Ac#|Cp%jlo zHPpuC%5jCNzMSaZm+iVUGY1Q58vr8M*&80vQ#8MNOz%F(Vzg0j_We6g(cUe;<}b5s zK)k@;IOEvdYAVYXuTHMTG(4^8bgrL=Ylr)hBG?a@@B{F;zd3>M0AKO6=xO>&R42 znkn^n=j6@sa8I>|)Yh!%;OrSMYIzYiTes0??70*!wEb=tB&4J~2O#W77mamK<}G1F z1Qg|49I)+cLO%8E9#HdSC3*)uYoTpIk(cFQskwPPVSFZ6N5rp5ZCvv&b>uo|c^^Hq znPsiBIgxU|N}Gy1LC)d+sTFBX_&g*LQyoU>IE`_xB__3Vm#bXA)+FV>w7i=3?PcH> z!ua4swOIEnGJnMQ9WDMn=;ItfVbc-l3ksFqD>xrP>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vp4K)atr^X51S9f5P$$HGra$PK^iJf;iMvXFn7Rd-TL@$h`RQ6+!Qug1Vo*j z)5RwFj07Prkq!aB7SPJWVta;Wg9iLv9-bB-wlw#ZFv<=|>zphZe{(!_IUP7>dI~bPg<#@&> zpORBE+|+2$pi4c$9WuVN#H`=MBi z7N)grPHTftE3sut+5UVR9C}y)NM4kOk%tu(aD17N|LU3b*8%JESz|pSrZp#5bYAK? z>sB`KyhEVJjX+Nwh`%SR0n|Wh8cM1lB~`U6s$d;eH61mzQy`EI2-M$EPuLXz^Yegu zA^!Dp9}|#bNMpqSX6LPp%Z%Kj F{sY9Y4G;hT literal 0 HcmV?d00001 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