UPDATE JS
This commit is contained in:
parent
cc4c2d632b
commit
947e7996aa
44
Script.js
44
Script.js
@ -13,6 +13,14 @@ var game = {
|
|||||||
timer: 0,
|
timer: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var keys = {
|
||||||
|
up: false,
|
||||||
|
down: false,
|
||||||
|
left: false,
|
||||||
|
right: false,
|
||||||
|
fire: false
|
||||||
|
}
|
||||||
|
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
init()
|
init()
|
||||||
}
|
}
|
||||||
@ -26,11 +34,43 @@ function init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function keyDownPressed(e) {
|
function keyDownPressed(e) {
|
||||||
|
if (e.keycode == 81) {
|
||||||
|
keys.up = true;
|
||||||
|
} else if (e.keycode == 65) {
|
||||||
|
keys.down = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function keyUpPressed(e){
|
if (e.keycode == 79) {
|
||||||
|
keys.left = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.keycode == 80) {
|
||||||
|
keys.right = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.keycode == 32) {
|
||||||
|
keys.fire = true;
|
||||||
|
alert("fire");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function keyUpPressed(e) {
|
||||||
|
if (e.keycode == 81) {
|
||||||
|
keys.up = false;
|
||||||
|
} else if (e.keycode == 65) {
|
||||||
|
keys.down = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.keycode == 79) {
|
||||||
|
keys.left = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.keycode == 80) {
|
||||||
|
keys.right = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.keycode == 32) {
|
||||||
|
keys.fire = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearGame() {
|
function clearGame() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user