mirror of
https://github.com/jiojciojsioe3/a3cjroijsiojiorj.git
synced 2024-11-15 07:21:50 +08:00
commit
2adbfc1e99
1
.gitignore
vendored
1
.gitignore
vendored
@ -42,4 +42,5 @@ Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
public/songs
|
||||
public/api
|
||||
taiko.db
|
@ -45,6 +45,7 @@
|
||||
<script type='application/javascript' src='/src/js/main.js'></script>
|
||||
<script type='application/javascript' src='/src/js/view.js'></script>
|
||||
<script type='application/javascript' src='/src/js/bufferedloop.js'></script>
|
||||
<script type='application/javascript' src='/src/js/mekadon.js'></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
@ -81,10 +81,12 @@ class BufferedLoop{
|
||||
},100)
|
||||
}
|
||||
pause(){
|
||||
var self=this
|
||||
clearInterval(this.interval)
|
||||
this.sources.forEach(function(sourceObject){
|
||||
sourceObject.source.stop(0)
|
||||
clearTimeout(sourceObject.timeout)
|
||||
self.sources.delete(sourceObject)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
function Controller(selectedSong, songData){
|
||||
function Controller(selectedSong, songData, autoPlayEnabled){
|
||||
|
||||
var _this = this;
|
||||
var _backgroundURL = "/songs/"+selectedSong.folder+"/bg.png";
|
||||
@ -8,6 +8,7 @@ function Controller(selectedSong, songData){
|
||||
|
||||
var _game = new Game(this, selectedSong, _songData);
|
||||
var _view = new View(this, _backgroundURL, selectedSong.title, selectedSong.difficulty);
|
||||
var _mekadon = new Mekadon(this, _game);
|
||||
var _keyboard = new Keyboard(this);
|
||||
var _mainLoop;
|
||||
var _pauseMenu = false;
|
||||
@ -124,7 +125,7 @@ function Controller(selectedSong, songData){
|
||||
assets.sounds["main-music"].currentTime=0;
|
||||
clearInterval(_mainLoop);
|
||||
$("#screen").load("/src/views/game.html", function(){
|
||||
var taikoGame = new Controller(selectedSong, songData);
|
||||
var taikoGame = new Controller(selectedSong, songData, autoPlayEnabled);
|
||||
taikoGame.run();
|
||||
});
|
||||
}
|
||||
@ -165,6 +166,10 @@ function Controller(selectedSong, songData){
|
||||
return _keyboard.getKeys();
|
||||
}
|
||||
|
||||
this.setKey = function(keyCode, down){
|
||||
return _keyboard.setKey(keyCode, down);
|
||||
}
|
||||
|
||||
this.getSongData = function(){
|
||||
return _game.getSongData();
|
||||
}
|
||||
@ -209,4 +214,13 @@ function Controller(selectedSong, songData){
|
||||
_game.updateGlobalScore(score);
|
||||
}
|
||||
|
||||
this.autoPlay = function(circle){
|
||||
if(autoPlayEnabled){
|
||||
if(circle && circle.getStatus() == 450){
|
||||
_mekadon.play(circle)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -118,6 +118,10 @@ function Game(controller, selectedSong, songData){
|
||||
|
||||
if(circle){
|
||||
|
||||
if(controller.autoPlay(circle)){
|
||||
return
|
||||
}
|
||||
|
||||
if(controller.getKeys()[86]){
|
||||
if(!circle.getPlayed() && !controller.isWaitingForKeyup(86, "score") && circle.getStatus()!=-1){
|
||||
var score = _this.checkScore(circle);
|
||||
|
@ -8,35 +8,54 @@ function Keyboard(controller){
|
||||
|
||||
$(document).keydown(function(e){
|
||||
|
||||
if (e.which === 8 && !$(e.target).is("input, textarea"))//disable back navigation when pressing backspace
|
||||
if (e.which === 8 && !$(e.target).is("input, textarea"))
|
||||
// Disable back navigation when pressing backspace
|
||||
e.preventDefault();
|
||||
|
||||
_keys[e.which]=true;
|
||||
if(_this.buttonEnabled(e.which)){
|
||||
_this.setKey(e.which, true);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).keyup(function(e){
|
||||
delete _keys[e.which];
|
||||
delete _waitKeyupScore[e.which];
|
||||
delete _waitKeyupSound[e.which];
|
||||
delete _waitKeyupMenu[e.which];
|
||||
if(_this.buttonEnabled(e.which)){
|
||||
_this.setKey(e.which, false);
|
||||
}
|
||||
});
|
||||
|
||||
this.buttonEnabled = function(keyCode){
|
||||
if(controller.autoPlay()){
|
||||
switch(keyCode){
|
||||
case 86:
|
||||
case 66:
|
||||
case 67:
|
||||
case 78:
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
this.checkGameKeys = function(){
|
||||
|
||||
if(_keys[86] && !_this.isWaitingForKeyup(86, "sound")){//if press v, play 'don' sound
|
||||
if(_keys[86] && !_this.isWaitingForKeyup(86, "sound")){
|
||||
// V, play 'don' sound
|
||||
controller.playSound('note_don');
|
||||
_this.waitForKeyup(86, "sound");
|
||||
}
|
||||
if(_keys[66] && !_this.isWaitingForKeyup(66, "sound")){//if press b, play 'don' sound
|
||||
if(_keys[66] && !_this.isWaitingForKeyup(66, "sound")){
|
||||
// B, play 'don' sound
|
||||
controller.playSound('note_don');
|
||||
_this.waitForKeyup(66, "sound");
|
||||
}
|
||||
|
||||
if(_keys[67] && !_this.isWaitingForKeyup(67, "sound")){//if press c, play 'ka' sound
|
||||
if(_keys[67] && !_this.isWaitingForKeyup(67, "sound")){
|
||||
// C, play 'ka' sound
|
||||
controller.playSound('note_ka');
|
||||
_this.waitForKeyup(67, "sound");
|
||||
}
|
||||
if(_keys[78] && !_this.isWaitingForKeyup(78, "sound")){//if press n, play 'ka' sound
|
||||
if(_keys[78] && !_this.isWaitingForKeyup(78, "sound")){
|
||||
// N, play 'ka' sound
|
||||
controller.playSound('note_ka');
|
||||
_this.waitForKeyup(78, "sound");
|
||||
}
|
||||
@ -45,12 +64,14 @@ function Keyboard(controller){
|
||||
|
||||
this.checkMenuKeys = function(){
|
||||
|
||||
if(_keys[8] && !_this.isWaitingForKeyup(8, "menu")){//If press return key, go back to song selection
|
||||
if(_keys[8] && !_this.isWaitingForKeyup(8, "menu")){
|
||||
// Backspace, go back to song selection
|
||||
_this.waitForKeyup(8, "menu");
|
||||
controller.pauseSound("main-music", true);
|
||||
controller.songSelection();
|
||||
}
|
||||
if(_keys[81] && !_this.isWaitingForKeyup(81, "menu")){//if press p key, pause the game
|
||||
if(_keys[81] && !_this.isWaitingForKeyup(81, "menu")){
|
||||
// Q, pause the game
|
||||
_this.waitForKeyup(81, "menu");
|
||||
controller.togglePauseMenu();
|
||||
}
|
||||
@ -61,6 +82,17 @@ function Keyboard(controller){
|
||||
return _keys;
|
||||
}
|
||||
|
||||
this.setKey=function(keyCode, down){
|
||||
if(down){
|
||||
_keys[keyCode]=true;
|
||||
}else{
|
||||
delete _keys[keyCode];
|
||||
delete _waitKeyupScore[keyCode];
|
||||
delete _waitKeyupSound[keyCode];
|
||||
delete _waitKeyupMenu[keyCode];
|
||||
}
|
||||
}
|
||||
|
||||
this.isWaitingForKeyup = function(key, type){
|
||||
var isWaiting;
|
||||
if(type == "score") isWaiting = _waitKeyupScore[key];
|
||||
|
@ -1,4 +1,4 @@
|
||||
function loadSong(selectedSong){
|
||||
function loadSong(selectedSong, autoPlayEnabled){
|
||||
|
||||
var _this = this;
|
||||
var _selectedSong=selectedSong;
|
||||
@ -46,7 +46,7 @@ function loadSong(selectedSong){
|
||||
this.checkIfEverythingLoaded = function(){
|
||||
if(_musicLoaded && _songDataLoaded && _bgLoaded){
|
||||
$("#screen").load("/src/views/game.html", function(){
|
||||
var taikoGame = new Controller(_selectedSong, _songData);
|
||||
var taikoGame = new Controller(_selectedSong, _songData, autoPlayEnabled);
|
||||
taikoGame.run();
|
||||
});
|
||||
}
|
||||
|
43
public/src/js/mekadon.js
Normal file
43
public/src/js/mekadon.js
Normal file
@ -0,0 +1,43 @@
|
||||
class Mekadon{
|
||||
constructor(controller, game){
|
||||
this.controller = controller
|
||||
this.game = game
|
||||
this.lr = false
|
||||
this.keys = {}
|
||||
}
|
||||
play(circle){
|
||||
if(circle.getType() == "don"){
|
||||
this.setKey(this.lr ? 86 : 66)
|
||||
this.lr = !this.lr
|
||||
}else if(circle.getType() == "daiDon"){
|
||||
this.setKey(86)
|
||||
this.setKey(66)
|
||||
this.lr = false
|
||||
}else if(circle.getType() == "ka"){
|
||||
this.setKey(this.lr ? 67 : 78)
|
||||
this.lr = !this.lr
|
||||
}else if(circle.getType() == "daiKa"){
|
||||
this.setKey(67)
|
||||
this.setKey(78)
|
||||
this.lr = false
|
||||
}
|
||||
var score = this.game.checkScore(circle);
|
||||
circle.played(score);
|
||||
this.game.updateCurrentCircle();
|
||||
}
|
||||
setKey(keyCode){
|
||||
var self = this
|
||||
if(this.keys[keyCode]){
|
||||
clearTimeout(this.keys[keyCode])
|
||||
self.clearKey(keyCode)
|
||||
}
|
||||
this.controller.setKey(keyCode, true)
|
||||
this.keys[keyCode] = setTimeout(function(){
|
||||
self.clearKey(keyCode)
|
||||
},100)
|
||||
}
|
||||
clearKey(keyCode){
|
||||
this.controller.setKey(keyCode, false)
|
||||
delete this.keys[keyCode]
|
||||
}
|
||||
}
|
@ -62,7 +62,7 @@ function SongSelect(){
|
||||
_selectedSong.folder = songID;
|
||||
|
||||
bgm.pause();
|
||||
new loadSong(_selectedSong);
|
||||
new loadSong(_selectedSong, e.shiftKey);
|
||||
});
|
||||
|
||||
$(".song").hover(function(){
|
||||
|
@ -29,6 +29,10 @@ function soundSystem(controller){
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.pauseSound = function(){
|
||||
_sounds["main-music"].pause();
|
||||
}
|
||||
|
||||
this.fadeOutMusic = function(){
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user