|
|
@ -4,6 +4,7 @@ player_pos = [0.5 * window.innerWidth, 0.9 * window.innerHeight];
|
|
|
|
enemy_pos = [0.5 * window.innerWidth, 0.1 * window.innerHeight];
|
|
|
|
enemy_pos = [0.5 * window.innerWidth, 0.1 * window.innerHeight];
|
|
|
|
new_enemy_pos = [enemy_pos[0], enemy_pos[1]];
|
|
|
|
new_enemy_pos = [enemy_pos[0], enemy_pos[1]];
|
|
|
|
pewpew = 0;
|
|
|
|
pewpew = 0;
|
|
|
|
|
|
|
|
herzles = 0;
|
|
|
|
|
|
|
|
|
|
|
|
document.onkeydown = onKeyDown;
|
|
|
|
document.onkeydown = onKeyDown;
|
|
|
|
|
|
|
|
|
|
|
@ -23,7 +24,7 @@ function onKeyDown(e) {
|
|
|
|
|
|
|
|
|
|
|
|
shoots = [];
|
|
|
|
shoots = [];
|
|
|
|
function shoot(pos) {
|
|
|
|
function shoot(pos) {
|
|
|
|
shoots[shoots.length] = [pos[0], pos[1]];
|
|
|
|
shoots[shoots.length] = [pos[0], pos[1], false];
|
|
|
|
// pewpew = 5;
|
|
|
|
// pewpew = 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -54,6 +55,10 @@ function detectCollisions() {
|
|
|
|
var shootdiv = document.getElementById('shoot' + i);
|
|
|
|
var shootdiv = document.getElementById('shoot' + i);
|
|
|
|
if (shootdiv && isCollided(shootdiv, enemydiv)) {
|
|
|
|
if (shootdiv && isCollided(shootdiv, enemydiv)) {
|
|
|
|
pewpew = 5;
|
|
|
|
pewpew = 5;
|
|
|
|
|
|
|
|
if (!shoots[i][2]) {
|
|
|
|
|
|
|
|
herzles++;
|
|
|
|
|
|
|
|
shoots[i][2] = true; // hit once
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -96,6 +101,12 @@ function render() {
|
|
|
|
pewpewdiv.innerHTML = "";
|
|
|
|
pewpewdiv.innerHTML = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// herzles
|
|
|
|
|
|
|
|
var herzlesdiv = document.getElementById("herzles");
|
|
|
|
|
|
|
|
if (herzles > 0) {
|
|
|
|
|
|
|
|
herzlesdiv.innerHTML = herzles + " <3";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// render player
|
|
|
|
// render player
|
|
|
|
var playerdiv = document.getElementById("player");
|
|
|
|
var playerdiv = document.getElementById("player");
|
|
|
|
playerdiv.style.left = (player_pos[0]
|
|
|
|
playerdiv.style.left = (player_pos[0]
|
|
|
|