From 7e3ec80526b6f8f023dac5475be1ddd2a6893948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Sun, 2 Dec 2018 14:44:01 +0900 Subject: [PATCH] Fix: Alien moveRandomPosition --- src/game/mouse/dodge/alien.js | 16 ++++++++++++---- src/game/mouse/dodge/game.js | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/game/mouse/dodge/alien.js b/src/game/mouse/dodge/alien.js index c97894b..5b91188 100644 --- a/src/game/mouse/dodge/alien.js +++ b/src/game/mouse/dodge/alien.js @@ -15,7 +15,7 @@ function Alien(spaceship) { game.add.existing(this); this.moveRandomPosition(); - this.setActive(true); + // this.setActive(true); } @@ -31,10 +31,18 @@ Alien.prototype.moveRandomPosition = function() { var posX = Math.sin(radians) * radious; var posY = Math.cos(radians) * radious; - this.x = this.spaceship.x + posX; - this.y = this.spaceship.y + posY; + this.x = game.world.centerX + posX; + this.y = game.world.centerY + posY; + // this.x = this.spaceship.x + posX; + // this.y = this.spaceship.y + posY; - this.angle = this.getSpriteAngle(this.angleFromAlien); + + var alienAngle = this.getAngle(this.spaceship.x, this.spaceship.y, this.x, this.y); + this.angle = this.getSpriteAngle(alienAngle); + + this.angleFromAlien = alienAngle; + + // this.angle = this.getSpriteAngle(this.angleFromAlien); } Alien.prototype.update = function() { diff --git a/src/game/mouse/dodge/game.js b/src/game/mouse/dodge/game.js index 219be24..90c321f 100644 --- a/src/game/mouse/dodge/game.js +++ b/src/game/mouse/dodge/game.js @@ -36,7 +36,7 @@ var Game = { this.spaceship = new Spaceship(); this.aliens = []; - for(var i = 0; i < 50; i++) { + for(var i = 0; i < 100; i++) { var alien = new Alien(this.spaceship); this.aliens.push(alien); }