[update] Implemented a damage effect.

This commit is contained in:
falsycat 2019-10-15 00:00:00 +00:00
parent 9cc07c0971
commit 111cd0f369
3 changed files with 15 additions and 1 deletions

View File

@ -12,7 +12,7 @@ class PostEffect {
struct Instance { struct Instance {
public: public:
/// ///
align(1) float raster_fineness = 0; align(1) float raster_fineness = 600;
/// ///
align(1) float raster_width = 0; align(1) float raster_width = 0;

View File

@ -15,6 +15,11 @@ import sjplayer.AbstractScheduledController,
/// ///
class PostEffectController : PostEffectScheduledController, PostEffectControllerInterface { class PostEffectController : PostEffectScheduledController, PostEffectControllerInterface {
public: public:
///
enum DamagedEffectLength = 30;
///
enum DamagedEffectRasterWidth = 0.1;
/// ///
this( this(
PostEffect posteffect, PostEffect posteffect,
@ -25,12 +30,20 @@ class PostEffectController : PostEffectScheduledController, PostEffectController
} }
override void CauseDamagedEffect() { override void CauseDamagedEffect() {
damaged_effect_frame_ = DamagedEffectLength;
} }
override void Update() { override void Update() {
if (damaged_effect_frame_ > 0) damaged_effect_frame_--;
posteffect_.raster_width =
damaged_effect_frame_*1f / DamagedEffectLength *
DamagedEffectRasterWidth;
} }
private: private:
PostEffect posteffect_; PostEffect posteffect_;
int damaged_effect_frame_;
} }
private alias PostEffectScheduledController = ScheduledController!( private alias PostEffectScheduledController = ScheduledController!(

View File

@ -60,6 +60,7 @@ int main(string[] args) {
const dmg = context.CalculateDamage(); const dmg = context.CalculateDamage();
if (dmg.damage != 0) { if (dmg.damage != 0) {
"damage: %f (%f)".writefln(dmg.damage, beat); "damage: %f (%f)".writefln(dmg.damage, beat);
context.posteffect.CauseDamagedEffect();
} }
if (dmg.nearness != 0) { if (dmg.nearness != 0) {
"nearby: %f (%f)".writefln(dmg.nearness, beat); "nearby: %f (%f)".writefln(dmg.nearness, beat);