From 111cd0f369ac85dadb5c61ca33441d98649dca94 Mon Sep 17 00:00:00 2001 From: falsycat Date: Tue, 15 Oct 2019 00:00:00 +0000 Subject: [PATCH] [update] Implemented a damage effect. --- sjplayer/src/sjplayer/PostEffect.d | 2 +- sjplayer/src/sjplayer/PostEffectController.d | 13 +++++++++++++ sjplayer/standalone/main.d | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sjplayer/src/sjplayer/PostEffect.d b/sjplayer/src/sjplayer/PostEffect.d index 15274f0..39038c2 100644 --- a/sjplayer/src/sjplayer/PostEffect.d +++ b/sjplayer/src/sjplayer/PostEffect.d @@ -12,7 +12,7 @@ class PostEffect { struct Instance { public: /// - align(1) float raster_fineness = 0; + align(1) float raster_fineness = 600; /// align(1) float raster_width = 0; diff --git a/sjplayer/src/sjplayer/PostEffectController.d b/sjplayer/src/sjplayer/PostEffectController.d index c907f0c..3885ab1 100644 --- a/sjplayer/src/sjplayer/PostEffectController.d +++ b/sjplayer/src/sjplayer/PostEffectController.d @@ -15,6 +15,11 @@ import sjplayer.AbstractScheduledController, /// class PostEffectController : PostEffectScheduledController, PostEffectControllerInterface { public: + /// + enum DamagedEffectLength = 30; + /// + enum DamagedEffectRasterWidth = 0.1; + /// this( PostEffect posteffect, @@ -25,12 +30,20 @@ class PostEffectController : PostEffectScheduledController, PostEffectController } override void CauseDamagedEffect() { + damaged_effect_frame_ = DamagedEffectLength; } override void Update() { + if (damaged_effect_frame_ > 0) damaged_effect_frame_--; + + posteffect_.raster_width = + damaged_effect_frame_*1f / DamagedEffectLength * + DamagedEffectRasterWidth; } private: PostEffect posteffect_; + + int damaged_effect_frame_; } private alias PostEffectScheduledController = ScheduledController!( diff --git a/sjplayer/standalone/main.d b/sjplayer/standalone/main.d index fc3dade..96056de 100644 --- a/sjplayer/standalone/main.d +++ b/sjplayer/standalone/main.d @@ -60,6 +60,7 @@ int main(string[] args) { const dmg = context.CalculateDamage(); if (dmg.damage != 0) { "damage: %f (%f)".writefln(dmg.damage, beat); + context.posteffect.CauseDamagedEffect(); } if (dmg.nearness != 0) { "nearby: %f (%f)".writefln(dmg.nearness, beat);