taiko-web/public/src/js/circle.js

73 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-09-15 16:34:53 +02:00
class Circle{
2018-09-20 01:20:26 +02:00
constructor(config){
// id, ms, type, text, speed, endTime, requiredHits
this.id = config.id
this.ms = config.start
this.type = config.type
this.text = config.txt
this.speed = config.speed
2018-09-21 22:31:35 +02:00
this.endTime = config.endTime || this.ms
this.isPlayed = 0
2018-09-15 16:34:53 +02:00
this.animating = false
this.animT = 0
this.score = 0
2018-09-20 01:20:26 +02:00
this.lastFrame = this.ms + 100
2018-09-15 16:34:53 +02:00
this.animationEnded = false
this.timesHit = 0
2018-09-20 01:20:26 +02:00
this.requiredHits = config.requiredHits || 0
this.rendaPlayed = false
2018-09-20 01:20:26 +02:00
this.gogoTime = config.gogoTime
this.gogoChecked = false
this.beatMS = config.beatMS
2018-09-15 16:34:53 +02:00
}
getMS(){
return this.ms
}
getEndTime(){
return this.endTime
}
getType(){
return this.type
}
getLastFrame(){
return this.lastFrame
}
animate(ms){
2018-09-15 16:34:53 +02:00
this.animating = true
this.animT = ms
2018-09-15 16:34:53 +02:00
}
isAnimated(){
return this.animating
}
getAnimT(){
return this.animT
}
getPlayed(){
return this.isPlayed
}
isAnimationFinished(){
return this.animationEnded
}
endAnimation(){
this.animationEnded = true
}
played(score, big){
2018-09-15 16:34:53 +02:00
this.score = score
2018-09-21 22:31:35 +02:00
this.isPlayed = score <= 0 ? score - 1 : (big ? 2 : 1)
2018-09-15 16:34:53 +02:00
}
hit(){
this.timesHit++
}
getScore(){
return this.score
}
getID(){
return this.id
}
getText(){
return this.text
}
getSpeed(){
return this.speed
}
2015-07-17 10:22:46 +02:00
}