Add: RecordUtil

This commit is contained in:
2018-12-03 00:25:16 +09:00
parent 057ac18184
commit eb61871526
12 changed files with 92 additions and 270 deletions
+19 -10
View File
@@ -8,7 +8,7 @@ function Missile(spaceship, onCollisionFunction) {
this.isActivated = false;
this.speed = Missile.DEFAULT_SPEED_DOT_PER_SEC;
this.boostSpeed = Missile.DEFAULT_SPEED_DOT_PER_SEC / 10;
this.boostSpeed = Missile.DEFAULT_SPEED_DOT_PER_SEC / 5;
this.angleFromSpaceship = 0;
this.angleFromMissile = 0;
@@ -22,7 +22,6 @@ function Missile(spaceship, onCollisionFunction) {
this.anchor.set(0.5);
game.add.existing(this);
// game.physics.enable(this, Phaser.Physics.ARCADE);
game.physics.arcade.enable(this);
this.moveRandomPosition();
@@ -32,8 +31,8 @@ function Missile(spaceship, onCollisionFunction) {
Missile.prototype.moveRandomPosition = function() {
// move random position
this.angleFromMissile = game.rnd.integerInRange(0, 360);
// console.log(this.angleFromMissile);
var radians = this.angleFromMissile * Math.PI / 180;
@@ -43,16 +42,22 @@ Missile.prototype.moveRandomPosition = function() {
this.x = game.world.centerX + posX;
this.y = game.world.centerY + posY;
// this.x = this.spaceship.x + posX;
// this.y = this.spaceship.y + posY;
var MissileAngle = this.getAngle(this.spaceship.x, this.spaceship.y, this.x, this.y);
// set missile direction
var spaceshipAreaX = this.spaceship.x + this.getRandomArea();
var spaceshipAreaY = this.spaceship.y + this.getRandomArea();
var MissileAngle = this.getAngle(spaceshipAreaX, spaceshipAreaY, this.x, this.y);
this.angle = this.getSpriteAngle(MissileAngle);
this.angleFromMissile = MissileAngle;
}
this.upgradeLevel();
Missile.prototype.getRandomArea = function() {
var randomValue = Math.random();
var randomArea = Missile.SPACESHIP_RANDOM_AREA_MARGIN * randomValue - Missile.SPACESHIP_RANDOM_AREA_MARGIN / 2;
return randomArea;
}
Missile.prototype.update = function() {
@@ -73,8 +78,10 @@ Missile.prototype.update = function() {
var distanceX = this.x - game.world.centerX;
var distanceY = this.y - game.world.centerY;
var distanceFromCenter = Math.sqrt(Math.abs(distanceX * distanceX) + Math.abs(distanceY * distanceY));
if(distanceFromCenter > this.responRadius)
if(distanceFromCenter > this.responRadius) {
this.moveRandomPosition();
this.upgradeLevel();
}
}
@@ -174,5 +181,7 @@ Missile.prototype.speedUp = function() {
Missile.DEFAULT_SPEED_DOT_PER_SEC = 150;
Missile.START_Radius_PX = 600;
Missile.START_RANDOM_Radius_PERCENT = 40;
Missile.START_Radius_PX = 600;
Missile.START_RANDOM_Radius_PERCENT = 40;
Missile.SPACESHIP_RANDOM_AREA_MARGIN = 100;