diff --git a/game.html b/game.html index 3867a85..a980be1 100644 --- a/game.html +++ b/game.html @@ -5,6 +5,7 @@ + @@ -39,7 +40,6 @@ -
diff --git a/scripts/enemy.js b/scripts/enemy.js index 20a547d..f21b1e6 100644 --- a/scripts/enemy.js +++ b/scripts/enemy.js @@ -1 +1,26 @@ -/* enemy spawning logic */ \ No newline at end of file +/* enemy spawning logic */ +var aliens = []; + +function spawnEnemy() { + var alien = document.createElement("div"); + alien.className = "alien"; + alien.id = "alien"; + while (true) { + alien.style.left = Math.floor(Math.random() * document.body.offsetWidth) + "px"; + if (document.elementFromPoint(alien.offsetLeft, alien.offsetTop).classList.contains("alien") == false) { + document.body.appendChild(alien); + aliens.push(alien); + break; + } + } +} + +function spawnBomb() { + var alien = aliens[0]; + var bomb = document.createElement("div"); + bomb.className = "bomb"; + bomb.style.left = "28px"; + bomb.style.top = "70px"; + bomb.style.zIndex = "-1"; + alien.appendChild(bomb); +} diff --git a/scripts/launch.js b/scripts/launch.js index 7b6a70e..abdf398 100644 --- a/scripts/launch.js +++ b/scripts/launch.js @@ -19,5 +19,6 @@ function load() { function startGame() { showDisplay("block"); document.getElementById("start").style.display = "none"; + document.getElementsByClassName("weapon")[0].style.display = "none"; } document.addEventListener("DOMContentLoaded", load);