2016-04-06 00:51:51 +02:00
|
|
|
var ani_ocean = OS.A.Add("Ocean", 256, 256, {columns: 10, speed: 1/120});
|
|
|
|
|
|
|
|
function oceanTilePrefab() {}
|
|
|
|
|
|
|
|
var pr_ocean = OS.P.Add("Ocean Particle", {
|
|
|
|
imageSrc: "images/ocean_sheet.png",
|
|
|
|
animations: [ani_ocean],
|
2016-04-06 01:33:38 +02:00
|
|
|
depth: -100, // Draw below everything.
|
2016-04-06 00:51:51 +02:00
|
|
|
|
|
|
|
positionCheckStep: 30,
|
|
|
|
positionCheckProgress: 30,
|
2016-04-06 01:59:10 +02:00
|
|
|
doCheckPosition: false
|
2016-04-06 00:51:51 +02:00
|
|
|
});
|
|
|
|
|
2016-04-06 01:33:38 +02:00
|
|
|
pr_ocean.BeforeDo = function () {
|
|
|
|
this.positionCheckProgress++;
|
|
|
|
if (this.positionCheckProgress >= this.positionCheckStep) {
|
|
|
|
this.positionCheckProgress = 0;
|
|
|
|
doCheckPosition = true;
|
|
|
|
}
|
|
|
|
}
|
2016-04-06 00:51:51 +02:00
|
|
|
pr_ocean.Do = function () {
|
2016-04-06 01:33:38 +02:00
|
|
|
// Move around randomly.
|
|
|
|
}
|
|
|
|
|
|
|
|
pr_ocean.CheckPosition = function (checkX, checkY) {
|
2016-04-06 00:51:51 +02:00
|
|
|
if (this.doCheckPosition) {
|
|
|
|
// If it's completely off the screen, then update position.
|
2016-04-06 01:33:38 +02:00
|
|
|
if ((Math.abs(this.x - checkX) > (OS.camera.width + this.xBound)) ||
|
|
|
|
(Math.abs(this.y - checkY) > (OS.camera.height + this.yBound)))
|
2016-04-06 00:51:51 +02:00
|
|
|
{
|
|
|
|
switch (pr_ship.direction) {
|
|
|
|
case 0:
|
2016-04-06 01:33:38 +02:00
|
|
|
this.x = G.player.x + (OS.camera.width + this.xBound) + randomSmidge();
|
|
|
|
this.y = G.player.y + randomSmidge();
|
2016-04-06 00:51:51 +02:00
|
|
|
break;
|
|
|
|
case 45:
|
2016-04-06 01:33:38 +02:00
|
|
|
this.x = G.player.x + (OS.camera.width + this.xBound) + randomSmidge();
|
|
|
|
this.y = G.player.y - (OS.camera.height + this.yBound) + randomSmidge();
|
2016-04-06 00:51:51 +02:00
|
|
|
break;
|
|
|
|
case 90:
|
2016-04-06 01:33:38 +02:00
|
|
|
this.x = G.player.x + randomSmidge();
|
|
|
|
this.y = G.player.y - (OS.camera.height + this.yBound) + randomSmidge();
|
2016-04-06 00:51:51 +02:00
|
|
|
break;
|
|
|
|
case 135:
|
2016-04-06 01:33:38 +02:00
|
|
|
this.x = G.player.x - (OS.camera.width + this.xBound) + randomSmidge();
|
|
|
|
this.y = G.player.y - (OS.camera.height + this.yBound) + randomSmidge();
|
2016-04-06 00:51:51 +02:00
|
|
|
break;
|
|
|
|
case 180:
|
2016-04-06 01:33:38 +02:00
|
|
|
this.x = G.player.x - (OS.camera.width + this.xBound) + randomSmidge();
|
|
|
|
this.y = G.player.y + randomSmidge();
|
2016-04-06 00:51:51 +02:00
|
|
|
break;
|
|
|
|
case 225:
|
2016-04-06 01:33:38 +02:00
|
|
|
this.x = G.player.x - (OS.camera.width + this.xBound) + randomSmidge();
|
|
|
|
this.y = G.player.y + (OS.camera.height + this.yBound) + randomSmidge();
|
2016-04-06 00:51:51 +02:00
|
|
|
break;
|
|
|
|
case 270:
|
2016-04-06 01:33:38 +02:00
|
|
|
this.x = G.player.x + randomSmidge();
|
|
|
|
this.y = G.player.y + (OS.camera.height + this.yBound) + randomSmidge();
|
2016-04-06 00:51:51 +02:00
|
|
|
break;
|
|
|
|
case 315:
|
2016-04-06 01:33:38 +02:00
|
|
|
this.x = G.player.x + (OS.camera.width + this.xBound) + randomSmidge();
|
|
|
|
this.y = G.player.y + (OS.camera.height + this.yBound) + randomSmidge();
|
2016-04-06 00:51:51 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.log("No valid direction");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-04-06 01:33:38 +02:00
|
|
|
|
|
|
|
this.doCheckPosition = false;
|
2016-04-06 00:51:51 +02:00
|
|
|
}
|
|
|
|
}
|