Fix drumroll, pressed keys, pause menu, hide cursor

This commit is contained in:
LoveEevee
2018-09-18 16:59:40 +03:00
parent 0a62088d62
commit 772dac579f
8 changed files with 118 additions and 82 deletions

View File

@@ -11,7 +11,7 @@ class CanvasAsset{
this.animationStart = 0
}
draw(){
var u = (a, b) => typeof a == "undefined" ? b : a
var u = (a, b) => typeof a === "undefined" ? b : a
var frame = 0
if(this.animation){
var ms = this.controller.getElapsedTime().ms
@@ -24,9 +24,9 @@ class CanvasAsset{
}
var index = Math.floor((ms - this.animationStart) / this.speed)
if(Array.isArray(this.animation)){
frame = this.animation[this.boundedIndex(this.animation.length, index)]
frame = this.animation[this.mod(this.animation.length, index)]
}else{
frame = this.boundedIndex(this.animation, index)
frame = this.mod(this.animation, index)
}
}
var pos = this.position(frame)
@@ -38,14 +38,8 @@ class CanvasAsset{
)
}
}
boundedIndex(length, index){
if(length == 0){
return
}
while(index < length){
index += length
}
return index % length
mod(length, index){
return ((index % length) + length) % length
}
addFrames(name, frames, image){
var framesObj = {
@@ -82,7 +76,7 @@ class CanvasAsset{
this.animationStart = ms
}
setAnimationEnd(ms, callback){
if(typeof ms == "undefined"){
if(typeof ms === "undefined"){
delete this.animationEnd
}else{
this.animationEnd = {