mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Move tests, create makefile action to run tests on examples (#433)
* Move tests, create makefile action to run tests on examples * Correct import file for html files * Build environment for tests * Fix the CI * rearrange CI * fix find cmd and make sure we don't delete the folder implicitly * more rearranging * fix folder permissions and custom sed for subfolders * add toga wheels files * re-add missing file * mirror latest changes in alpha ci * fix find cmd * try different fix for find * remove redundant build Co-authored-by: mariana <marianameireles@protonmail.com> Co-authored-by: pww217 <pwilson@anaconda.com> Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
This commit is contained in:
54
examples/mario/js/input.js
Normal file
54
examples/mario/js/input.js
Normal file
@@ -0,0 +1,54 @@
|
||||
(function() {
|
||||
var pressedKeys = {};
|
||||
|
||||
function setKey(event, status) {
|
||||
var code = event.keyCode;
|
||||
var key;
|
||||
|
||||
switch(code) {
|
||||
case 32:
|
||||
key = 'SPACE'; break;
|
||||
case 37:
|
||||
key = 'LEFT'; break;
|
||||
case 38:
|
||||
key = 'UP'; break;
|
||||
case 39:
|
||||
key = 'RIGHT'; break;
|
||||
case 40:
|
||||
key = 'DOWN'; break;
|
||||
case 88:
|
||||
key = 'JUMP'; break;
|
||||
case 90:
|
||||
key = 'RUN'; break;
|
||||
default:
|
||||
key = String.fromCharCode(code);
|
||||
}
|
||||
|
||||
pressedKeys[key] = status;
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', function(e) {
|
||||
setKey(e, true);
|
||||
});
|
||||
|
||||
document.addEventListener('keyup', function(e) {
|
||||
setKey(e, false);
|
||||
});
|
||||
|
||||
window.addEventListener('blur', function() {
|
||||
pressedKeys = {};
|
||||
});
|
||||
|
||||
window.input = {
|
||||
isDown: function(key) {
|
||||
return pressedKeys[key.toUpperCase()];
|
||||
},
|
||||
reset: function() {
|
||||
pressedKeys['RUN'] = false;
|
||||
pressedKeys['LEFT'] = false;
|
||||
pressedKeys['RIGHT'] = false;
|
||||
pressedKeys['DOWN'] = false;
|
||||
pressedKeys['JUMP'] = false;
|
||||
}
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user