From acbf384e2af0503c6564188c1f896e82d006da25 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Thu, 20 Mar 2025 04:25:15 -0400 Subject: [PATCH] Fixed some of the easing functions but still not sure with RAT_GIANT doesn't move. --- animation.cpp | 10 ++++++---- assets/enemies.json | 2 +- easings.hpp | 7 ++++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/animation.cpp b/animation.cpp index bb63322..db431ac 100644 --- a/animation.cpp +++ b/animation.cpp @@ -10,17 +10,19 @@ namespace components { } float Animation::twitching() { + float tick = ease::sine(float(frames) / subframe * ease_rate); + switch(easing) { case ease::NONE: return 0.0; case ease::SINE: - return ease::sine(float(frames) / subframe * ease_rate); + return tick; case ease::OUT_CIRC: - return ease::out_circ(ease::sine(float(frames) / subframe * ease_rate)); + return ease::out_circ(tick); case ease::OUT_BOUNCE: - return ease::out_bounce(ease::sine(float(frames) / subframe * ease_rate)); + return ease::sine(ease::out_bounce(tick)); case ease::IN_OUT_BACK: - return ease::in_out_back(ease::sine(float(frames) / subframe * ease_rate)); + return ease::sine(ease::in_out_back(tick)); default: dbc::sentinel( fmt::format("Invalid easing {} given to animation", diff --git a/assets/enemies.json b/assets/enemies.json index e14949a..e1d8b48 100644 --- a/assets/enemies.json +++ b/assets/enemies.json @@ -51,7 +51,7 @@ {"_type": "Motion", "dx": 0, "dy": 0, "random": false}, {"_type": "EnemyConfig", "ai_script": "Enemy::actions", "ai_start_name": "Enemy::initial_state", "ai_goal_name": "Enemy::final_state"}, {"_type": "Personality", "hearing_distance": 5, "tough": false}, - {"_type": "Animation", "easing": 3, "ease_rate": 0.5, "scale": 0.1, "simple": true, "frames": 10, "speed": 1.0, "stationary": false}, + {"_type": "Animation", "easing": 3, "ease_rate": 0.5, "scale": 0.1, "simple": true, "frames": 1, "speed": 1.0, "stationary": false}, {"_type": "Sprite", "name": "rat_with_sword", "width": 256, "height": 256, "scale": 1.0}, {"_type": "Sound", "attack": "Small_Rat", "death": "Creature_Death_1"} ] diff --git a/easings.hpp b/easings.hpp index 9a05a33..871d791 100644 --- a/easings.hpp +++ b/easings.hpp @@ -4,7 +4,12 @@ namespace ease { enum Style { - NONE, SINE, OUT_CIRC, OUT_BOUNCE, IN_OUT_BACK, FUCKFACE + NONE=0, + SINE=1, + OUT_CIRC=2, + OUT_BOUNCE=3, + IN_OUT_BACK=4, + FUCKFACE }; inline double sine(double x) {