Now have the ability to place animated fixtures anywhere and to flip them.
This commit is contained in:
parent
e99c07b50c
commit
387d1a5bf5
7 changed files with 36 additions and 17 deletions
|
|
@ -142,7 +142,7 @@
|
||||||
"speed": 0.02,
|
"speed": 0.02,
|
||||||
"stationary": true
|
"stationary": true
|
||||||
},
|
},
|
||||||
"torch_crappy": {
|
"torch_fixture": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 0,
|
"easing": 0,
|
||||||
"ease_rate": 0.5,
|
"ease_rate": 0.5,
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,8 @@
|
||||||
"sprite": "rat_king_boss"
|
"sprite": "rat_king_boss"
|
||||||
},
|
},
|
||||||
"fixtures": [
|
"fixtures": [
|
||||||
{"name": "torch_crappy", "scale": 0.8, "cell": "torch1"},
|
{"name": "torch_fixture", "scale_x": 0.5, "scale_y": 0.5, "cell": "torch1", "x": 66, "y": -10},
|
||||||
{"name": "torch_crappy", "scale": 0.8, "cell": "torch2"},
|
{"name": "torch_fixture", "scale_x": -0.5, "scale_y": 0.5, "cell": "torch2", "x": 130, "y": -10}
|
||||||
{"name": "rat_with_sword", "scale": 0.8, "cell": "boss13"},
|
|
||||||
{"name": "rat_with_sword", "scale": 0.8, "cell": "boss16"}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{"_type": "Combat", "hp": 20, "max_hp": 20, "damage": 20, "dead": false},
|
{"_type": "Combat", "hp": 20, "max_hp": 20, "damage": 20, "dead": false},
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,11 @@
|
||||||
"frame_width": 256,
|
"frame_width": 256,
|
||||||
"frame_height": 256
|
"frame_height": 256
|
||||||
},
|
},
|
||||||
|
"torch_fixture":
|
||||||
|
{"path": "assets/fixtures/torch_fixture.png",
|
||||||
|
"frame_width": 256,
|
||||||
|
"frame_height": 256
|
||||||
|
},
|
||||||
"torch_crappy":
|
"torch_crappy":
|
||||||
{"path": "assets/items/torch_crappy.png",
|
{"path": "assets/items/torch_crappy.png",
|
||||||
"frame_width": 256,
|
"frame_width": 256,
|
||||||
|
|
|
||||||
BIN
assets/fixtures/torch_fixture.png
Normal file
BIN
assets/fixtures/torch_fixture.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
28
boss/ui.cpp
28
boss/ui.cpp
|
|
@ -6,6 +6,8 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include "sound.hpp"
|
#include "sound.hpp"
|
||||||
|
|
||||||
|
const bool DEBUG=false;
|
||||||
|
|
||||||
namespace boss {
|
namespace boss {
|
||||||
using namespace guecs;
|
using namespace guecs;
|
||||||
|
|
||||||
|
|
@ -35,10 +37,13 @@ namespace boss {
|
||||||
st.sprite = std::make_shared<sf::Sprite>(*st.texture);
|
st.sprite = std::make_shared<sf::Sprite>(*st.texture);
|
||||||
|
|
||||||
auto anim = animation::load(name);
|
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"];
|
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"]);
|
move_player($scene.player["start_pos"]);
|
||||||
|
|
||||||
if($scene.floor) {
|
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) {
|
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();
|
$arena.init();
|
||||||
|
|
@ -89,13 +95,13 @@ namespace boss {
|
||||||
$combat_ui.init(cell.x, cell.y, cell.w, cell.h);
|
$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);
|
auto& cell = $arena.cell_for(cell_name);
|
||||||
float x = float(at_mid ? cell.mid_x : cell.x);
|
float x = float(at_mid ? cell.mid_x : cell.x);
|
||||||
float y = float(at_mid ? cell.mid_y : cell.y);
|
float y = float(at_mid ? cell.mid_y : cell.y);
|
||||||
|
|
||||||
st.sprite->setPosition({x, y});
|
st.sprite->setPosition({x + x_diff, y + y_diff});
|
||||||
st.sprite->setScale({scale, scale});
|
st.sprite->setScale({scale_x, scale_y});
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::render(sf::RenderWindow& window) {
|
void UI::render(sf::RenderWindow& window) {
|
||||||
|
|
@ -114,6 +120,8 @@ namespace boss {
|
||||||
|
|
||||||
window.draw(*$boss_sprite.sprite);
|
window.draw(*$boss_sprite.sprite);
|
||||||
window.draw(*$player_sprite.sprite);
|
window.draw(*$player_sprite.sprite);
|
||||||
|
|
||||||
|
if(DEBUG) $arena.debug_layout(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UI::mouse(float x, float y, Modifiers mods) {
|
bool UI::mouse(float x, float y, Modifiers mods) {
|
||||||
|
|
@ -127,14 +135,16 @@ namespace boss {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::move_boss(const std::string& cell_name) {
|
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);
|
auto& cell = $arena.cell_for(cell_name);
|
||||||
$boss_pos = {float(cell.mid_x), float(cell.mid_y)};
|
$boss_pos = {float(cell.mid_x), float(cell.mid_y)};
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::move_player(const std::string& cell_name) {
|
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) {
|
void UI::play_animations(sf::RenderWindow& window) {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,11 @@ struct AnimatedFixture {
|
||||||
textures::SpriteTexture st;
|
textures::SpriteTexture st;
|
||||||
components::Animation anim;
|
components::Animation anim;
|
||||||
std::string cell;
|
std::string cell;
|
||||||
float scale;
|
float scale_x;
|
||||||
|
float scale_y;
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
bool at_mid=false;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace boss {
|
namespace boss {
|
||||||
|
|
@ -39,7 +43,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& 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 status(const std::wstring& msg);
|
||||||
void move_boss(const std::string& cell_name);
|
void move_boss(const std::string& cell_name);
|
||||||
void move_player(const std::string& cell_name);
|
void move_player(const std::string& cell_name);
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,9 @@ function Build-Images {
|
||||||
# Build-Images -Source "Items" -pixel_count 2
|
# Build-Images -Source "Items" -pixel_count 2
|
||||||
# Build-Images -Source "Animations" -pixel_count 6
|
# Build-Images -Source "Animations" -pixel_count 6
|
||||||
# Build-Images -Source "Hands" -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
|
#magick montage -tile 3x1 -geometry +0+0 -background transparent .\assets\hands\female_hand_*.png .\assets\hands\female_hand.png
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue