From dad50ed02ff36f95999ab7cc07c69b56518fc599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Afonso=20Fran=C3=A7a?= Date: Wed, 17 Apr 2013 01:24:12 -0300 Subject: [PATCH] Saving in dropbox, load games from dropbox and keyboard usable --- index.html | 121 ++++++++++++++++++++++++++++++++++++++++++++++++ scripts/init.js | 51 ++++++++++++++++++-- 2 files changed, 167 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 57e49ed..6ec7f7b 100644 --- a/index.html +++ b/index.html @@ -35,6 +35,8 @@ + +
@@ -46,5 +48,124 @@
+
Salvar no Dropbox
+
Carregar do Dropbox

+
Abrir jogo do Dropbox
+ + + \ No newline at end of file diff --git a/scripts/init.js b/scripts/init.js index ec64c62..a009df9 100644 --- a/scripts/init.js +++ b/scripts/init.js @@ -168,9 +168,53 @@ $(window).load(function () { jQueryClickmask .on('mousedown', function(event) { event.preventDefault(); - GameBoyKeyDown(id); + GameBoyKeyDown($(this).attr('id')); }).on('mouseup', function () { - GameBoyKeyUp(id); + GameBoyKeyUp($(this).attr('id')); + }); + + function getKey(event) + { + if(event.keyCode == 37) + { + return "left"; + } + if(event.keyCode == 38) + { + return "up"; + } + if(event.keyCode == 39) + { + return "right"; + } + if(event.keyCode == 40) + { + return "down"; + } + if(event.keyCode == 13) + { + return "start"; + } + if(event.keyCode == 17) + { + return "select"; + } + if(event.keyCode == 88) + { + return "b"; + } + if(event.keyCode == 90) + { + return "a"; + } + } + + $(document) + .on('keydown', function(event) { + event.preventDefault(); + GameBoyKeyDown(getKey(event)); + }).on('keyup', function () { + GameBoyKeyUp(getKey(event)); }); } @@ -226,7 +270,4 @@ $(window).load(function () { $(document).preventUIActions(); $(config.controls.bothSideSelector).documents().preventUIActions(); - - $.getScript('./demo.js'); - }); \ No newline at end of file