Remove hardcoded keyCodes

This commit is contained in:
LoveEevee
2018-08-29 08:58:03 +03:00
parent 5a82469da5
commit 64a93f14ab
5 changed files with 91 additions and 97 deletions

View File

@@ -117,48 +117,36 @@ function Game(controller, selectedSong, songData){
var circle = circles[_currentCircle];
if(circle){
if(controller.autoPlay(circle)){
return
if(controller.autoPlayEnabled){
return controller.autoPlay(circle)
}
if(controller.getKeys()[86]){
if(!circle.getPlayed() && !controller.isWaitingForKeyup(86, "score") && circle.getStatus()!=-1){
var score = _this.checkScore(circle);
circle.played(score);
_this.updateCurrentCircle();
controller.waitForKeyup(86, "score");
}
var keys = controller.getKeys()
var kbd = controller.getBindings()
if(keys[kbd["don_l"]]){
_this.checkKey(kbd["don_l"], circle)
}
if(controller.getKeys()[66]){
if(!circle.getPlayed() && !controller.isWaitingForKeyup(66, "score") && circle.getStatus()!=-1){
var score = _this.checkScore(circle);
circle.played(score);
_this.updateCurrentCircle();
controller.waitForKeyup(66, "score");
}
if(keys[kbd["don_r"]]){
_this.checkKey(kbd["don_r"], circle)
}
if(controller.getKeys()[67]){
if(!circle.getPlayed() && !controller.isWaitingForKeyup(67, "score") && circle.getStatus()!=-1){
var score = _this.checkScore(circle);
circle.played(score);
_this.updateCurrentCircle();
controller.waitForKeyup(67, "score");
}
if(keys[kbd["ka_l"]]){
_this.checkKey(kbd["ka_l"], circle)
}
if(controller.getKeys()[78]){
if(!circle.getPlayed() && !controller.isWaitingForKeyup(78, "score") && circle.getStatus()!=-1){
var score = _this.checkScore(circle);
circle.played(score);
_this.updateCurrentCircle();
controller.waitForKeyup(78, "score");
}
if(keys[kbd["ka_r"]]){
_this.checkKey(kbd["ka_r"], circle)
}
}
}
this.checkKey = function(keyCode, circle){
if(!circle.getPlayed() && !controller.isWaitingForKeyup(keyCode, "score") && circle.getStatus()!=-1){
var score = _this.checkScore(circle);
circle.played(score);
_this.updateCurrentCircle();
controller.waitForKeyup(keyCode, "score");
}
}
this.checkScore = function(circle){
if(