Better easings and motion but I need better data.
This commit is contained in:
parent
f8158a3ea9
commit
949bbd4f15
10 changed files with 75 additions and 17 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
#include "animation.hpp"
|
#include "animation.hpp"
|
||||||
|
#include "rand.hpp"
|
||||||
|
|
||||||
namespace components {
|
namespace components {
|
||||||
void Animation::play() {
|
void Animation::play() {
|
||||||
|
|
@ -10,7 +11,7 @@ namespace components {
|
||||||
}
|
}
|
||||||
|
|
||||||
float Animation::twitching() {
|
float Animation::twitching() {
|
||||||
float tick = ease::sine(float(frames) / subframe * ease_rate);
|
float tick = ease::sine(float(frames) / (subframe + 0.0001) * ease_rate);
|
||||||
|
|
||||||
switch(easing) {
|
switch(easing) {
|
||||||
case ease::NONE:
|
case ease::NONE:
|
||||||
|
|
@ -23,6 +24,10 @@ namespace components {
|
||||||
return ease::sine(ease::out_bounce(tick));
|
return ease::sine(ease::out_bounce(tick));
|
||||||
case ease::IN_OUT_BACK:
|
case ease::IN_OUT_BACK:
|
||||||
return ease::sine(ease::in_out_back(tick));
|
return ease::sine(ease::in_out_back(tick));
|
||||||
|
case ease::RANDOM:
|
||||||
|
return Random::uniform_real(0.0001f, 1.0f);
|
||||||
|
case ease::NORM_DIST:
|
||||||
|
return Random::normal(0.5f, 0.1f);
|
||||||
default:
|
default:
|
||||||
dbc::sentinel(
|
dbc::sentinel(
|
||||||
fmt::format("Invalid easing {} given to animation",
|
fmt::format("Invalid easing {} given to animation",
|
||||||
|
|
@ -38,9 +43,36 @@ namespace components {
|
||||||
float tick = twitching();
|
float tick = twitching();
|
||||||
|
|
||||||
if(stationary) {
|
if(stationary) {
|
||||||
scale_out.x = std::lerp(scale_x, max_scale, tick);
|
switch(motion) {
|
||||||
scale_out.y = std::lerp(scale_y, max_scale, tick);
|
case ease::SHAKE: {
|
||||||
pos_out.y = pos_out.y - (pos_out.y * scale_out.y - pos_out.y);
|
pos_out.x += std::lerp(scale_x, max_scale, tick);
|
||||||
|
} break;
|
||||||
|
case ease::BOUNCE: {
|
||||||
|
pos_out.y -= std::lerp(scale_y, max_scale, tick);
|
||||||
|
} break;
|
||||||
|
case ease::RUSH: {
|
||||||
|
scale_out.x = std::lerp(scale_x, max_scale, tick);
|
||||||
|
scale_out.y = std::lerp(scale_y, max_scale, tick);
|
||||||
|
pos_out.y = pos_out.y - (pos_out.y * scale_out.y - pos_out.y);
|
||||||
|
} break;
|
||||||
|
case ease::SQUEEZE: {
|
||||||
|
scale_out.x *= std::lerp(scale_x, max_scale, tick);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case ease::SQUASH: {
|
||||||
|
scale_out.y *= std::lerp(scale_y, max_scale, tick);
|
||||||
|
} break;
|
||||||
|
case ease::STRETCH: {
|
||||||
|
scale_out.x = std::lerp(scale_x, max_scale, tick);
|
||||||
|
fmt::println("scale_x: {} max_scale: {} tick: {} scale_out.x: {}",
|
||||||
|
scale_x, max_scale, tick, scale_out.x);
|
||||||
|
} break;
|
||||||
|
case ease::GROW: {
|
||||||
|
scale_out.y = std::lerp(scale_y, max_scale, tick);
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
dbc::sentinel("Unknown animation.motion setting.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
scale_out.x = std::lerp(scale_out.x * scale_x, scale_out.x * max_scale, tick);
|
scale_out.x = std::lerp(scale_out.x * scale_x, scale_out.x * max_scale, tick);
|
||||||
scale_out.y = std::lerp(scale_out.y * scale_y, scale_out.y * max_scale, tick);
|
scale_out.y = std::lerp(scale_out.y * scale_y, scale_out.y * max_scale, tick);
|
||||||
|
|
@ -86,7 +118,11 @@ namespace animation {
|
||||||
|
|
||||||
sprite.setTextureRect(rect);
|
sprite.setTextureRect(rect);
|
||||||
sprite.setPosition(pos);
|
sprite.setPosition(pos);
|
||||||
sprite.setScale(scale);
|
|
||||||
|
// BUG: make this an option: apply_scale, apply_position and ranges for x y
|
||||||
|
if(anim.motion != ease::SHAKE && anim.motion != ease::BOUNCE && anim.motion != ease::RUSH) {
|
||||||
|
sprite.setScale(scale);
|
||||||
|
}
|
||||||
|
|
||||||
return anim.playing;
|
return anim.playing;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
"burning_animation": {
|
"burning_animation": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 0,
|
"easing": 0,
|
||||||
|
"motion": 0,
|
||||||
"ease_rate": 0.5,
|
"ease_rate": 0.5,
|
||||||
"scale_x": 1.0,
|
"scale_x": 1.0,
|
||||||
"scale_y": 1.0,
|
"scale_y": 1.0,
|
||||||
|
|
@ -16,6 +17,7 @@
|
||||||
"male_hand": {
|
"male_hand": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 0,
|
"easing": 0,
|
||||||
|
"motion": 0,
|
||||||
"ease_rate": 0.5,
|
"ease_rate": 0.5,
|
||||||
"scale_x": 1.0,
|
"scale_x": 1.0,
|
||||||
"scale_y": 1.0,
|
"scale_y": 1.0,
|
||||||
|
|
@ -30,6 +32,7 @@
|
||||||
"female_hand": {
|
"female_hand": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 0,
|
"easing": 0,
|
||||||
|
"motion": 0,
|
||||||
"ease_rate": 0.5,
|
"ease_rate": 0.5,
|
||||||
"scale_x": 1.0,
|
"scale_x": 1.0,
|
||||||
"scale_y": 1.0,
|
"scale_y": 1.0,
|
||||||
|
|
@ -44,6 +47,7 @@
|
||||||
"lightning_animation": {
|
"lightning_animation": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 0,
|
"easing": 0,
|
||||||
|
"motion": 0,
|
||||||
"ease_rate": 0.5,
|
"ease_rate": 0.5,
|
||||||
"scale_x": 1.0,
|
"scale_x": 1.0,
|
||||||
"scale_y": 1.0,
|
"scale_y": 1.0,
|
||||||
|
|
@ -58,6 +62,7 @@
|
||||||
"ritual_crafting_area": {
|
"ritual_crafting_area": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 0,
|
"easing": 0,
|
||||||
|
"motion": 0,
|
||||||
"ease_rate": 0.5,
|
"ease_rate": 0.5,
|
||||||
"scale_x": 1.0,
|
"scale_x": 1.0,
|
||||||
"scale_y": 1.0,
|
"scale_y": 1.0,
|
||||||
|
|
@ -72,6 +77,7 @@
|
||||||
"peasant_girl_rear_view": {
|
"peasant_girl_rear_view": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 3,
|
"easing": 3,
|
||||||
|
"motion": 0,
|
||||||
"ease_rate": 0.2,
|
"ease_rate": 0.2,
|
||||||
"scale_x": 0.5,
|
"scale_x": 0.5,
|
||||||
"scale_y": 0.5,
|
"scale_y": 0.5,
|
||||||
|
|
@ -86,6 +92,7 @@
|
||||||
"gold_savior": {
|
"gold_savior": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 1,
|
"easing": 1,
|
||||||
|
"motion": 0,
|
||||||
"ease_rate": 0.2,
|
"ease_rate": 0.2,
|
||||||
"scale_x": 1.1,
|
"scale_x": 1.1,
|
||||||
"scale_y": 1.1,
|
"scale_y": 1.1,
|
||||||
|
|
@ -100,6 +107,7 @@
|
||||||
"armored_knight" : {
|
"armored_knight" : {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 1,
|
"easing": 1,
|
||||||
|
"motion": 0,
|
||||||
"ease_rate": 0.2,
|
"ease_rate": 0.2,
|
||||||
"scale_x": 1.1,
|
"scale_x": 1.1,
|
||||||
"scale_y": 1.1,
|
"scale_y": 1.1,
|
||||||
|
|
@ -114,6 +122,7 @@
|
||||||
"axe_ranger": {
|
"axe_ranger": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 3,
|
"easing": 3,
|
||||||
|
"motion": 0,
|
||||||
"ease_rate": 0.5,
|
"ease_rate": 0.5,
|
||||||
"scale_x": 1.1,
|
"scale_x": 1.1,
|
||||||
"scale_y": 1.1,
|
"scale_y": 1.1,
|
||||||
|
|
@ -128,6 +137,7 @@
|
||||||
"rat_with_sword": {
|
"rat_with_sword": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 3,
|
"easing": 3,
|
||||||
|
"motion": 0,
|
||||||
"ease_rate": 0.5,
|
"ease_rate": 0.5,
|
||||||
"scale_x": 1.0,
|
"scale_x": 1.0,
|
||||||
"scale_y": 1.0,
|
"scale_y": 1.0,
|
||||||
|
|
@ -142,6 +152,7 @@
|
||||||
"hairy_spider": {
|
"hairy_spider": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 2,
|
"easing": 2,
|
||||||
|
"motion": 0,
|
||||||
"ease_rate": 0.5,
|
"ease_rate": 0.5,
|
||||||
"scale_x": 0.9,
|
"scale_x": 0.9,
|
||||||
"scale_y": 0.9,
|
"scale_y": 0.9,
|
||||||
|
|
@ -156,6 +167,7 @@
|
||||||
"test_boss": {
|
"test_boss": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 1,
|
"easing": 1,
|
||||||
|
"motion": 0,
|
||||||
"ease_rate": 0.5,
|
"ease_rate": 0.5,
|
||||||
"scale_x": 0.4,
|
"scale_x": 0.4,
|
||||||
"scale_y": 0.4,
|
"scale_y": 0.4,
|
||||||
|
|
@ -170,10 +182,11 @@
|
||||||
"rat_king_boss": {
|
"rat_king_boss": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 4,
|
"easing": 4,
|
||||||
"ease_rate": 0.9,
|
"motion": 0,
|
||||||
|
"ease_rate": 0.5,
|
||||||
"scale_x": 0.6,
|
"scale_x": 0.6,
|
||||||
"scale_y": 0.6,
|
"scale_y": 0.6,
|
||||||
"max_scale": 0.7,
|
"max_scale": 2.0,
|
||||||
"simple": false,
|
"simple": false,
|
||||||
"frames": 2,
|
"frames": 2,
|
||||||
"speed": 0.02,
|
"speed": 0.02,
|
||||||
|
|
@ -184,6 +197,7 @@
|
||||||
"torch_fixture": {
|
"torch_fixture": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 0,
|
"easing": 0,
|
||||||
|
"motion": 0,
|
||||||
"ease_rate": 0.5,
|
"ease_rate": 0.5,
|
||||||
"scale_x": 0.5,
|
"scale_x": 0.5,
|
||||||
"scale_y": 0.5,
|
"scale_y": 0.5,
|
||||||
|
|
@ -198,6 +212,7 @@
|
||||||
"test_floor": {
|
"test_floor": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 2,
|
"easing": 2,
|
||||||
|
"motion": 0,
|
||||||
"ease_rate": 0.5,
|
"ease_rate": 0.5,
|
||||||
"scale_x": 1.0,
|
"scale_x": 1.0,
|
||||||
"scale_y": 1.0,
|
"scale_y": 1.0,
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
|
|
@ -105,7 +105,7 @@ namespace boss {
|
||||||
break;
|
break;
|
||||||
case ATTACK: {
|
case ATTACK: {
|
||||||
$ui.status(L"BOSS TURN");
|
$ui.status(L"BOSS TURN");
|
||||||
$ui.move_actor("boss", run % 10 < 5 ? "boss5" : "boss6");
|
// $ui.move_actor("boss", run % 10 < 5 ? "boss5" : "boss6");
|
||||||
$ui.animate_actor("boss");
|
$ui.animate_actor("boss");
|
||||||
int attack_id = std::any_cast<int>(data);
|
int attack_id = std::any_cast<int>(data);
|
||||||
boss::System::combat(attack_id);
|
boss::System::combat(attack_id);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
#include "boss/ui.hpp"
|
#include "boss/ui.hpp"
|
||||||
#include "scene.hpp"
|
#include "scene.hpp"
|
||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
#include <chrono>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
namespace boss {
|
namespace boss {
|
||||||
using namespace guecs;
|
using namespace guecs;
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ namespace components {
|
||||||
int frames = 10;
|
int frames = 10;
|
||||||
float speed = 0.3f;
|
float speed = 0.3f;
|
||||||
ease::Style easing = ease::IN_OUT_BACK;
|
ease::Style easing = ease::IN_OUT_BACK;
|
||||||
|
ease::Motion motion = ease::RUSH;
|
||||||
float ease_rate = 0.5f;
|
float ease_rate = 0.5f;
|
||||||
bool stationary = false;
|
bool stationary = false;
|
||||||
bool toggled = false;
|
bool toggled = false;
|
||||||
|
|
@ -161,7 +162,7 @@ namespace components {
|
||||||
ENROLL_COMPONENT(Combat, hp, max_hp, damage, dead);
|
ENROLL_COMPONENT(Combat, hp, max_hp, damage, dead);
|
||||||
ENROLL_COMPONENT(Device, config, events);
|
ENROLL_COMPONENT(Device, config, events);
|
||||||
ENROLL_COMPONENT(Animation, scale_x, scale_y, max_scale, simple, frames,
|
ENROLL_COMPONENT(Animation, scale_x, scale_y, max_scale, simple, frames,
|
||||||
speed, easing, ease_rate, stationary, toggled, looped);
|
speed, easing, motion, ease_rate, stationary, toggled, looped);
|
||||||
ENROLL_COMPONENT(Sound, attack, death);
|
ENROLL_COMPONENT(Sound, attack, death);
|
||||||
ENROLL_COMPONENT(Collision, has);
|
ENROLL_COMPONENT(Collision, has);
|
||||||
|
|
||||||
|
|
|
||||||
13
easings.hpp
13
easings.hpp
|
|
@ -9,7 +9,18 @@ namespace ease {
|
||||||
OUT_CIRC=2,
|
OUT_CIRC=2,
|
||||||
OUT_BOUNCE=3,
|
OUT_BOUNCE=3,
|
||||||
IN_OUT_BACK=4,
|
IN_OUT_BACK=4,
|
||||||
FUCKFACE
|
RANDOM=5,
|
||||||
|
NORM_DIST=6
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Motion {
|
||||||
|
RUSH=0,
|
||||||
|
SHAKE=1,
|
||||||
|
BOUNCE=2,
|
||||||
|
SQUEEZE=3,
|
||||||
|
SQUASH=4,
|
||||||
|
STRETCH=5,
|
||||||
|
GROW=6
|
||||||
};
|
};
|
||||||
|
|
||||||
inline double sine(double x) {
|
inline double sine(double x) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
const bool DEBUG=false;
|
const bool DEBUG=false;
|
||||||
const bool YOU_REMOVED_MID_CELL_IDIOT=false;
|
|
||||||
|
|
||||||
namespace scene {
|
namespace scene {
|
||||||
Element config_scene_element(nlohmann::json& config, bool and_play, bool duped) {
|
Element config_scene_element(nlohmann::json& config, bool and_play, bool duped) {
|
||||||
|
|
@ -18,8 +17,6 @@ namespace scene {
|
||||||
// BUG: need to make animation optional
|
// BUG: need to make animation optional
|
||||||
auto anim = animation::load(sprite_name);
|
auto anim = animation::load(sprite_name);
|
||||||
if(and_play) anim.play();
|
if(and_play) anim.play();
|
||||||
anim.scale_x = scale_x;
|
|
||||||
anim.scale_y = scale_y;
|
|
||||||
|
|
||||||
std::string cell = config["cell"];
|
std::string cell = config["cell"];
|
||||||
std::string name = config["name"];
|
std::string name = config["name"];
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@ 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 24
|
# Build-Images -Source "Animations" -pixel_count 24
|
||||||
# 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
|
# Build-Images -Source "Fixtures" -pixel_count 24
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue