Merge pull request #33 from LoveEevee/two-animations

Add clear and endclear animations
This commit is contained in:
Bui 2018-09-26 06:04:47 +01:00 committed by GitHub
commit 74a9813c14
6 changed files with 32 additions and 13 deletions

View File

@ -1,24 +1,17 @@
@-webkit-keyframes bgscroll{
from{
background-position: 0 0;
}
to{
background-position: -200px 0;
}
}
@keyframes bgscroll{ @keyframes bgscroll{
from{ from{
background-position: 0 0; background-position: 0 0;
} }
to{ to{
background-position: -200px 0; background-position: -30vmin 0;
} }
} }
#song-select{ #song-select{
width: 100%; width: 100%;
height: 100%; height: 100%;
background: url("/assets/img/bg-pattern-1.png"); background: url("/assets/img/bg-pattern-1.png");
animation: bgscroll 3s infinite linear; background-size: 30vmin;
animation: bgscroll 8s infinite linear;
white-space: nowrap; white-space: nowrap;
} }
#song-container{ #song-container{

View File

@ -31,6 +31,8 @@ var assets = {
"don_anim_10combo.png", "don_anim_10combo.png",
"don_anim_gogo.png", "don_anim_gogo.png",
"don_anim_gogostart.png", "don_anim_gogostart.png",
"don_anim_clear.png",
"don_anim_endclear.png",
"fire_anim.png", "fire_anim.png",
"fireworks_anim.png" "fireworks_anim.png"
], ],

View File

@ -107,6 +107,7 @@ class Controller{
this.view.togglePauseMenu() this.view.togglePauseMenu()
} }
gameEnded(){ gameEnded(){
this.view.gameEnded()
var score = this.getGlobalScore() var score = this.getGlobalScore()
var vp var vp
if(score.fail === 0){ if(score.fail === 0){

View File

@ -281,7 +281,7 @@ class Game{
var ms = this.getElapsedTime().ms var ms = this.getElapsedTime().ms
if(this.musicFadeOut === 0){ if(this.musicFadeOut === 0){
if(this.controller.multiplayer === 1){ if(this.controller.multiplayer === 1){
p2.send("gameresults", this.controller.getGlobalScore()) p2.send("gameresults", this.getGlobalScore())
} }
this.musicFadeOut++ this.musicFadeOut++
}else if(this.musicFadeOut === 1 && ms >= started + 1600){ }else if(this.musicFadeOut === 1 && ms >= started + 1600){

View File

@ -749,7 +749,8 @@ class View{
}) })
} }
}else{ }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() this.assets.don.normalAnimation()
} }
if(ms >= this.gogoTimeStarted + 100){ if(ms >= this.gogoTimeStarted + 100){
@ -770,10 +771,24 @@ class View{
don.setAnimation("10combo") don.setAnimation("10combo")
var ms = this.controller.getElapsedTime().ms var ms = this.controller.getElapsedTime().ms
don.setAnimationStart(ms) don.setAnimationStart(ms)
var length = don.getAnimationLength("normal")
don.setUpdateSpeed(this.beatInterval / (length / 4))
var length = don.getAnimationLength("10combo") var length = don.getAnimationLength("10combo")
don.setAnimationEnd(ms + length * don.speed, don.normalAnimation) 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){ onmousemove(event){
this.lastMousemove = this.controller.getElapsedTime().ms this.lastMousemove = this.controller.getElapsedTime().ms
this.cursorHidden = false this.cursorHidden = false

View File

@ -42,12 +42,20 @@ class ViewAssets{
var length = this.don.getAnimationLength("gogo") var length = this.don.getAnimationLength("gogo")
this.don.setUpdateSpeed(this.beatInterval / (length / 4)) this.don.setUpdateSpeed(this.beatInterval / (length / 4))
this.don.setAnimation("gogo") 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{ }else{
this.don.setAnimationStart(0) 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.setAnimation("normal")
} }
} }
this.don.addFrames("clear", 30, "don_anim_clear")
this.don.addFrames("endclear", 22, "don_anim_endclear")
this.don.normalAnimation() this.don.normalAnimation()
this.fire = this.createAsset("bar", frame => { this.fire = this.createAsset("bar", frame => {
var imgw = 360 var imgw = 360