|
|
|
@ -3,33 +3,33 @@
|
|
|
|
|
<head>
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
|
|
player_pos = [300, 0];
|
|
|
|
|
enemy_pos = [300, 0];
|
|
|
|
|
pewpew = 0;
|
|
|
|
|
player_pos = [300, 0];
|
|
|
|
|
enemy_pos = [300, 0];
|
|
|
|
|
pewpew = 0;
|
|
|
|
|
|
|
|
|
|
document.onkeydown = onKeyDown;
|
|
|
|
|
document.onkeydown = onKeyDown;
|
|
|
|
|
|
|
|
|
|
function onKeyDown(e) {
|
|
|
|
|
e = e || window.event;
|
|
|
|
|
function onKeyDown(e) {
|
|
|
|
|
e = e || window.event;
|
|
|
|
|
|
|
|
|
|
var player = document.getElementById("player");
|
|
|
|
|
var player = document.getElementById("player");
|
|
|
|
|
|
|
|
|
|
if (e.keyCode == '37') { // left
|
|
|
|
|
player_pos[0] -= 10;
|
|
|
|
|
}
|
|
|
|
|
if (e.keyCode == '39') { // right
|
|
|
|
|
player_pos[0] += 10;
|
|
|
|
|
}
|
|
|
|
|
if (e.keyCode == '32') { // space = fire
|
|
|
|
|
shoot(player_pos);
|
|
|
|
|
}
|
|
|
|
|
if (e.keyCode == '37') { // left
|
|
|
|
|
player_pos[0] -= 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shoots = [];
|
|
|
|
|
function shoot(player_pos) {
|
|
|
|
|
shoots[shoots.length] = [player_pos[0], 500];
|
|
|
|
|
// pewpew = 5;
|
|
|
|
|
if (e.keyCode == '39') { // right
|
|
|
|
|
player_pos[0] += 10;
|
|
|
|
|
}
|
|
|
|
|
if (e.keyCode == '32') { // space = fire
|
|
|
|
|
shoot(player_pos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shoots = [];
|
|
|
|
|
function shoot(player_pos) {
|
|
|
|
|
shoots[shoots.length] = [player_pos[0], 500];
|
|
|
|
|
// pewpew = 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isCollided(a, b) {
|
|
|
|
|
var a_left = parseInt(a.style.left);
|
|
|
|
|