Skip to content

Commit

Permalink
Distributing enemies more evenly (not just spawning them at the corners)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunraz committed Sep 13, 2014
1 parent 389b22a commit ce109aa
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ loop.start(function frame(deltaT) {

if(player.health <= 0) {
if(controls.states.shoot && gameOverTimer <= 0) {
resetGame();
}
resetGame();
}

gameOverTimer -= deltaT;
}
Expand All @@ -53,8 +53,10 @@ loop.start(function frame(deltaT) {

function placeRandomEnemy() {
if(player.health > 0) {
var x = player.x + Math.sign(Math.random() - 0.5) * 100;
var y = player.y + Math.sign(Math.random() - 0.5) * 100;
var rad = Math.random() * 2 * Math.PI;

var x = player.x + 100 * Math.cos(rad);
var y = player.y + 100 * Math.sin(rad);

entities.push(new Enemy(x, y));
}
Expand Down

0 comments on commit ce109aa

Please sign in to comment.