From fa818ad370c9daaf02f07c3136775b989f686180 Mon Sep 17 00:00:00 2001 From: LoveEevee Date: Wed, 26 Sep 2018 03:26:42 +0300 Subject: [PATCH] Add clear and endclear animations --- public/src/css/songselect.css | 13 +++---------- public/src/js/assets.js | 2 ++ public/src/js/controller.js | 1 + public/src/js/game.js | 2 +- public/src/js/view.js | 17 ++++++++++++++++- public/src/js/viewassets.js | 10 +++++++++- 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/public/src/css/songselect.css b/public/src/css/songselect.css index 6addc3f..5da8c5f 100644 --- a/public/src/css/songselect.css +++ b/public/src/css/songselect.css @@ -1,24 +1,17 @@ -@-webkit-keyframes bgscroll{ - from{ - background-position: 0 0; - } - to{ - background-position: -200px 0; - } -} @keyframes bgscroll{ from{ background-position: 0 0; } to{ - background-position: -200px 0; + background-position: -30vmin 0; } } #song-select{ width: 100%; height: 100%; background: url("/assets/img/bg-pattern-1.png"); - animation: bgscroll 3s infinite linear; + background-size: 30vmin; + animation: bgscroll 8s infinite linear; white-space: nowrap; } #song-container{ diff --git a/public/src/js/assets.js b/public/src/js/assets.js index dda9af1..9d8603b 100644 --- a/public/src/js/assets.js +++ b/public/src/js/assets.js @@ -31,6 +31,8 @@ var assets = { "don_anim_10combo.png", "don_anim_gogo.png", "don_anim_gogostart.png", + "don_anim_clear.png", + "don_anim_endclear.png", "fire_anim.png", "fireworks_anim.png" ], diff --git a/public/src/js/controller.js b/public/src/js/controller.js index e276f9d..85e4b94 100644 --- a/public/src/js/controller.js +++ b/public/src/js/controller.js @@ -107,6 +107,7 @@ class Controller{ this.view.togglePauseMenu() } gameEnded(){ + this.view.gameEnded() var score = this.getGlobalScore() var vp if(score.fail === 0){ diff --git a/public/src/js/game.js b/public/src/js/game.js index d208b1e..1c9ec94 100644 --- a/public/src/js/game.js +++ b/public/src/js/game.js @@ -281,7 +281,7 @@ class Game{ var ms = this.getElapsedTime().ms if(this.musicFadeOut === 0){ if(this.controller.multiplayer === 1){ - p2.send("gameresults", this.controller.getGlobalScore()) + p2.send("gameresults", this.getGlobalScore()) } this.musicFadeOut++ }else if(this.musicFadeOut === 1 && ms >= started + 1600){ diff --git a/public/src/js/view.js b/public/src/js/view.js index ac32dec..7a71f41 100644 --- a/public/src/js/view.js +++ b/public/src/js/view.js @@ -749,7 +749,8 @@ class View{ }) } }else{ - if(this.assets.don.getAnimation() === "gogo"){ + var animation = this.assets.don.getAnimation() + if(animation === "gogo" || this.controller.getGlobalScore().hp >= 50 && animation === "normal"){ this.assets.don.normalAnimation() } if(ms >= this.gogoTimeStarted + 100){ @@ -770,10 +771,24 @@ class View{ don.setAnimation("10combo") var ms = this.controller.getElapsedTime().ms don.setAnimationStart(ms) + var length = don.getAnimationLength("normal") + don.setUpdateSpeed(this.beatInterval / (length / 4)) var length = don.getAnimationLength("10combo") don.setAnimationEnd(ms + length * don.speed, don.normalAnimation) } } + gameEnded(){ + if(this.controller.getGlobalScore().hp >= 50){ + var don = this.assets.don + don.setAnimation("endclear") + var ms = this.controller.getElapsedTime().ms + don.setAnimationStart(ms) + var length = don.getAnimationLength("normal") + don.setUpdateSpeed(this.beatInterval / (length / 4)) + var length = don.getAnimationLength("endclear") + don.setAnimationEnd(ms + length * don.speed, don.normalAnimation) + } + } onmousemove(event){ this.lastMousemove = this.controller.getElapsedTime().ms this.cursorHidden = false diff --git a/public/src/js/viewassets.js b/public/src/js/viewassets.js index 0faa67c..00063e8 100644 --- a/public/src/js/viewassets.js +++ b/public/src/js/viewassets.js @@ -42,12 +42,20 @@ class ViewAssets{ var length = this.don.getAnimationLength("gogo") this.don.setUpdateSpeed(this.beatInterval / (length / 4)) this.don.setAnimation("gogo") + }else if(this.controller.getGlobalScore().hp >= 50){ + this.don.setAnimationStart(0) + var length = this.don.getAnimationLength("clear") + this.don.setUpdateSpeed(this.beatInterval / (length / 2)) + this.don.setAnimation("clear") }else{ this.don.setAnimationStart(0) - this.don.setUpdateSpeed(this.beatInterval / 16) + var length = this.don.getAnimationLength("normal") + this.don.setUpdateSpeed(this.beatInterval / (length / 4)) this.don.setAnimation("normal") } } + this.don.addFrames("clear", 30, "don_anim_clear") + this.don.addFrames("endclear", 22, "don_anim_endclear") this.don.normalAnimation() this.fire = this.createAsset("bar", frame => { var imgw = 360