From cdb0f435b744f0a1695d99d9b2076ccee84636df Mon Sep 17 00:00:00 2001 From: neingeist Date: Tue, 14 Aug 2012 23:02:01 +0200 Subject: [PATCH] animate enemy --- herzle.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/herzle.html b/herzle.html index 214c4fe..a328bf4 100644 --- a/herzle.html +++ b/herzle.html @@ -108,7 +108,7 @@ function gameLoop() { // animate shoots for(var i = 0; i < shoots.length; i++) { if (shoots[i]) { - shoots[i][1] -= 10; + shoots[i][1] -= 20; if (shoots[i][1] < 0) { delete(shoots[i]); } @@ -120,6 +120,14 @@ function gameLoop() { pewpew -= 1; } + // animate enemy + var min = -50; + var max = +50; + var off = min + parseInt(Math.random() * (max-min)); + enemy_pos[0] += off; + if (enemy_pos[0] < 0) enemy_pos[0] = 0; + if (enemy_pos[0] > 600) enemy_pos[0] = 600; + setTimeout("gameLoop()", 100); }