neingeist
/
30shooter
Archived
1
0
Fork 0
master
neingeist 12 years ago
parent d461213cae
commit f342a8399a

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