Now have a fancy hand animation when you cast your rituals.
This commit is contained in:
parent
ad3e580495
commit
7af264e147
9 changed files with 43 additions and 8 deletions
|
|
@ -81,7 +81,6 @@ namespace animation {
|
||||||
sprite.setPosition(pos);
|
sprite.setPosition(pos);
|
||||||
sprite.setScale(scale);
|
sprite.setScale(scale);
|
||||||
|
|
||||||
|
|
||||||
return anim.playing;
|
return anim.playing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,6 +104,10 @@ namespace animation {
|
||||||
for(auto& [name, data] : animations.json().items()) {
|
for(auto& [name, data] : animations.json().items()) {
|
||||||
try {
|
try {
|
||||||
auto anim = components::convert<Animation>(data);
|
auto anim = components::convert<Animation>(data);
|
||||||
|
|
||||||
|
dbc::check(sprites.contains(name),
|
||||||
|
fmt::format("animation '{}' doesn't have sprite, spelled wrong in config.json?", name));
|
||||||
|
|
||||||
auto& sprite_config = sprites[name];
|
auto& sprite_config = sprites[name];
|
||||||
|
|
||||||
anim.frame_width = sprite_config["frame_width"];
|
anim.frame_width = sprite_config["frame_width"];
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,16 @@
|
||||||
"speed": 0.1,
|
"speed": 0.1,
|
||||||
"stationary": false
|
"stationary": false
|
||||||
},
|
},
|
||||||
|
"hand": {
|
||||||
|
"_type": "Animation",
|
||||||
|
"easing": 0,
|
||||||
|
"ease_rate": 0.5,
|
||||||
|
"scale": 1.0,
|
||||||
|
"simple": false,
|
||||||
|
"frames": 3,
|
||||||
|
"speed": 0.1,
|
||||||
|
"stationary": false
|
||||||
|
},
|
||||||
"lightning_animation": {
|
"lightning_animation": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 0,
|
"easing": 0,
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,11 @@
|
||||||
{"path": "assets/sprites/dead_body_lootable.png",
|
{"path": "assets/sprites/dead_body_lootable.png",
|
||||||
"frame_width": 256,
|
"frame_width": 256,
|
||||||
"frame_height": 256
|
"frame_height": 256
|
||||||
|
},
|
||||||
|
"hand":
|
||||||
|
{"path": "assets/hands/hands.png",
|
||||||
|
"frame_width": 900,
|
||||||
|
"frame_height": 600
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"worldgen": {
|
"worldgen": {
|
||||||
|
|
|
||||||
BIN
assets/hands/hands.png
Normal file
BIN
assets/hands/hands.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
|
|
@ -243,6 +243,7 @@ namespace gui {
|
||||||
run_systems();
|
run_systems();
|
||||||
break;
|
break;
|
||||||
case ATTACK:
|
case ATTACK:
|
||||||
|
$main_ui.play_hands();
|
||||||
$main_ui.dirty();
|
$main_ui.dirty();
|
||||||
sound::play("Sword_Hit_1");
|
sound::play("Sword_Hit_1");
|
||||||
state(State::ATTACKING);
|
state(State::ATTACKING);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,9 @@ namespace gui {
|
||||||
|
|
||||||
MainUI::MainUI(sf::RenderWindow& window) :
|
MainUI::MainUI(sf::RenderWindow& window) :
|
||||||
$window(window),
|
$window(window),
|
||||||
$rayview(std::make_shared<Raycaster>(RAY_VIEW_WIDTH, RAY_VIEW_HEIGHT))
|
$rayview(std::make_shared<Raycaster>(RAY_VIEW_WIDTH, RAY_VIEW_HEIGHT)),
|
||||||
|
$hand(textures::get_sprite("hand")),
|
||||||
|
$hand_anim(animation::load("hand"))
|
||||||
{
|
{
|
||||||
$window.setVerticalSyncEnabled(VSYNC);
|
$window.setVerticalSyncEnabled(VSYNC);
|
||||||
$window.setFramerateLimit(FRAME_LIMIT);
|
$window.setFramerateLimit(FRAME_LIMIT);
|
||||||
|
|
@ -39,6 +41,8 @@ namespace gui {
|
||||||
|
|
||||||
if($mind_reading) render_mind_reading();
|
if($mind_reading) render_mind_reading();
|
||||||
$overlay_ui.render($window);
|
$overlay_ui.render($window);
|
||||||
|
|
||||||
|
if($hand_anim.playing) render_hands();
|
||||||
}
|
}
|
||||||
|
|
||||||
lel::Cell MainUI::overlay_cell(const std::string& name) {
|
lel::Cell MainUI::overlay_cell(const std::string& name) {
|
||||||
|
|
@ -133,4 +137,15 @@ namespace gui {
|
||||||
void MainUI::mouse(int x, int y, guecs::Modifiers mods) {
|
void MainUI::mouse(int x, int y, guecs::Modifiers mods) {
|
||||||
$overlay_ui.$gui.mouse(x, y, mods);
|
$overlay_ui.$gui.mouse(x, y, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainUI::play_hands() {
|
||||||
|
$hand_anim.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainUI::render_hands() {
|
||||||
|
if(animation::apply($hand_anim, *$hand.sprite)) {
|
||||||
|
$hand.sprite->setPosition({RAY_VIEW_X, RAY_VIEW_Y});
|
||||||
|
$window.draw(*$hand.sprite);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "gui/overlay_ui.hpp"
|
#include "gui/overlay_ui.hpp"
|
||||||
#include "gui/debug_ui.hpp"
|
#include "gui/debug_ui.hpp"
|
||||||
#include "raycaster.hpp"
|
#include "raycaster.hpp"
|
||||||
|
#include "animation.hpp"
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
|
|
@ -19,6 +20,8 @@ namespace gui {
|
||||||
sf::RenderWindow& $window;
|
sf::RenderWindow& $window;
|
||||||
OverlayUI $overlay_ui;
|
OverlayUI $overlay_ui;
|
||||||
std::shared_ptr<Raycaster> $rayview;
|
std::shared_ptr<Raycaster> $rayview;
|
||||||
|
textures::SpriteTexture $hand;
|
||||||
|
components::Animation $hand_anim;
|
||||||
|
|
||||||
MainUI(sf::RenderWindow& window);
|
MainUI(sf::RenderWindow& window);
|
||||||
|
|
||||||
|
|
@ -41,5 +44,7 @@ namespace gui {
|
||||||
void dead_entity(DinkyECS::Entity entity);
|
void dead_entity(DinkyECS::Entity entity);
|
||||||
void toggle_mind_reading();
|
void toggle_mind_reading();
|
||||||
void render_mind_reading();
|
void render_mind_reading();
|
||||||
|
void play_hands();
|
||||||
|
void render_hands();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ function Build-Images {
|
||||||
# Build-Images -Source "Textures" -pixel_count 12
|
# Build-Images -Source "Textures" -pixel_count 12
|
||||||
# Build-Images -Source "Sprites" -pixel_count 6
|
# Build-Images -Source "Sprites" -pixel_count 6
|
||||||
# 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 2
|
||||||
|
|
||||||
cp -recurse -force C:\Users\lcthw\Pictures\Games\Renders\Raycaster\UI assets\ui
|
cp -recurse -force C:\Users\lcthw\Pictures\Games\Renders\Raycaster\UI assets\ui
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,6 @@ TEST_CASE("animation easing tests", "[animation]") {
|
||||||
anim.easing = ease::IN_OUT_BACK;
|
anim.easing = ease::IN_OUT_BACK;
|
||||||
res = anim.twitching();
|
res = anim.twitching();
|
||||||
REQUIRE(!std::isnan(res));
|
REQUIRE(!std::isnan(res));
|
||||||
|
|
||||||
anim.easing = ease::FUCKFACE;
|
|
||||||
bool throws = false;
|
|
||||||
try { anim.twitching(); } catch(...) { throws = true; }
|
|
||||||
REQUIRE(throws);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue