Made edits to try to make island generation better. It crashes on load a lot on Ubuntu Chrome for some reason. No clue why.
This commit is contained in:
parent
d7201a5eb2
commit
34de633ef3
|
@ -11,6 +11,7 @@ var ct_shift = OS.C.Add("Shift", OS.Keycode.shift);
|
||||||
var ct_space = OS.C.Add("Space", OS.Keycode.space);
|
var ct_space = OS.C.Add("Space", OS.Keycode.space);
|
||||||
var ct_z = OS.C.Add("Z", OS.Keycode.z);
|
var ct_z = OS.C.Add("Z", OS.Keycode.z);
|
||||||
var ct_x = OS.C.Add("X", OS.Keycode.x);
|
var ct_x = OS.C.Add("X", OS.Keycode.x);
|
||||||
|
var ct_m = OS.C.Add("M", OS.Keycode.m);
|
||||||
var ct_esc = OS.C.Add("Cancel", OS.Keycode.escape);
|
var ct_esc = OS.C.Add("Cancel", OS.Keycode.escape);
|
||||||
|
|
||||||
function loadControls () {}
|
function loadControls () {}
|
||||||
|
|
|
@ -6,6 +6,7 @@ var pr_island = OS.P.Add("Island", {
|
||||||
solid: true,
|
solid: true,
|
||||||
imageSrc: "images/island.png",
|
imageSrc: "images/island.png",
|
||||||
animations: [ani_island_1],
|
animations: [ani_island_1],
|
||||||
|
depth: -50,
|
||||||
|
|
||||||
mapX: 0,
|
mapX: 0,
|
||||||
mapY: 0,
|
mapY: 0,
|
||||||
|
|
|
@ -74,7 +74,7 @@ pr_ship.AfterDo = function () {
|
||||||
pr_ship.GetMapPosition = function () {
|
pr_ship.GetMapPosition = function () {
|
||||||
this.mapX = pixel(Math.round(this.x / pixel(64)));
|
this.mapX = pixel(Math.round(this.x / pixel(64)));
|
||||||
this.mapY = pixel(Math.round(this.y / pixel(64)));
|
this.mapY = pixel(Math.round(this.y / pixel(64)));
|
||||||
console.log(this.mapX + ", " + this.mapY);
|
// console.log(this.mapX + ", " + this.mapY);
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_ship.CheckInteraction = function () {
|
pr_ship.CheckInteraction = function () {
|
||||||
|
|
|
@ -59,12 +59,16 @@ rm_Ocean.Do = function () {
|
||||||
this.waveTimer = Math.round(Math.randomRange(30, 150));
|
this.waveTimer = Math.round(Math.randomRange(30, 150));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (guiControl && guiControl.inventory && guiControl.trade) { // Force it to wait until loaded.
|
if (guiControl && guiControl.inventory && guiControl.map && guiControl.trade) { // Force it to wait until loaded.
|
||||||
if (!guiControl.inventory.show && !guiControl.map.show && !guiControl.trade.show) {
|
if (!guiControl.inventory.show && !guiControl.map.show && !guiControl.trade.show) {
|
||||||
if (ct_cancel().down) {
|
if (ct_cancel().down) {
|
||||||
guiControl.inventory.activateDelay = 5;
|
guiControl.inventory.activateDelay = 5;
|
||||||
guiControl.inventory.show = true;
|
guiControl.inventory.show = true;
|
||||||
}
|
}
|
||||||
|
if (ct_m.down) {
|
||||||
|
guiControl.map.activateDelay = 5;
|
||||||
|
guiControl.map.show = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,54 +151,47 @@ rm_Ocean.DrawClock = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
rm_Ocean.GenerateMap = function () {
|
rm_Ocean.GenerateMap = function () {
|
||||||
var island1 = rm_Ocean.AddObject(OS.P["Island"], {
|
var xSquares = [25];
|
||||||
x: pixel(64) * 25, //Exact center of map.
|
var ySquares = [22];
|
||||||
y: pixel(64) * 22
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(island1.name + " created at " + island1.x + ", " + island1.y);
|
while(xSquares.length < 10){
|
||||||
G.map.push({
|
var randomX = Math.round(Math.randomRange(1, 48));
|
||||||
island: island1,
|
var foundX = false;
|
||||||
drawX: 25,
|
for(var i = 0; i < xSquares.length; i++){
|
||||||
drawY: 22,
|
// console.log(i + ": " + (xSquares[i] - 3) + " <= " + randomX + " <= " + (xSquares[i] + 3) + "?");
|
||||||
drawWidth: 1,
|
if (randomX >= xSquares[i] - 3 && randomX <= xSquares[i] + 3) {
|
||||||
drawHeight: 1
|
foundX = true;
|
||||||
});
|
break;
|
||||||
|
|
||||||
var usedXSquares = [];
|
|
||||||
var usedYSquares = [];
|
|
||||||
for (var i = 0; i < 9; i++) {
|
|
||||||
var xSquare = Math.round(Math.randomRange(1, 49));
|
|
||||||
while (usedXSquares.indexOf(xSquare) != -1 &&
|
|
||||||
usedXSquares.indexOf(xSquare + 1) != -1 && usedXSquares.indexOf(xSquare - 1) != -1 &&
|
|
||||||
usedXSquares.indexOf(xSquare + 2) != -1 && usedXSquares.indexOf(xSquare - 2) != -1)
|
|
||||||
{
|
|
||||||
xSquare = Math.round(Math.randomRange(1, 49));
|
|
||||||
}
|
}
|
||||||
usedXSquares.push(xSquare);
|
|
||||||
|
|
||||||
var ySquare = Math.round(Math.randomRange(1, 43));
|
|
||||||
while (usedYSquares.indexOf(ySquare) != -1 &&
|
|
||||||
usedYSquares.indexOf(ySquare + 1) != -1 && usedYSquares.indexOf(ySquare - 1) != -1 &&
|
|
||||||
usedYSquares.indexOf(ySquare + 2) != -1 && usedYSquares.indexOf(ySquare - 2) != -1)
|
|
||||||
{
|
|
||||||
ySquare = Math.round(Math.randomRange(1, 49));
|
|
||||||
}
|
}
|
||||||
usedYSquares.push(ySquare);
|
if (!foundX) xSquares[xSquares.length] = randomX;
|
||||||
|
}
|
||||||
var xPosition = pixel(64) * xSquare;
|
while(ySquares.length < 10){
|
||||||
var yPosition = pixel(64) * ySquare;
|
var randomY = Math.round(Math.randomRange(1, 42));
|
||||||
|
var foundY = false;
|
||||||
|
for(var i = 0; i < ySquares.length; i++){
|
||||||
|
// console.log(i + ": " + (ySquares[i] - 3) + " <= " + randomY + " <= " + (ySquares[i] + 3) + "?");
|
||||||
|
if (randomY >= ySquares[i] - 3 && randomY <= ySquares[i] + 3) {
|
||||||
|
foundY = true;
|
||||||
|
// console.log("It's between! Do not add!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!foundY) ySquares[ySquares.length] = randomY;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < xSquares.length; i++) {
|
||||||
G.map.push({
|
G.map.push({
|
||||||
island: rm_Ocean.AddObject(OS.P["Island"], {
|
island: rm_Ocean.AddObject(OS.P["Island"], {
|
||||||
x: xPosition,
|
x: pixel(64) * xSquares[i],
|
||||||
y: yPosition
|
y: pixel(64) * ySquares[i]
|
||||||
}),
|
}),
|
||||||
drawX: xSquare,
|
drawX: xSquares[i],
|
||||||
drawY: ySquare,
|
drawY: ySquares[i],
|
||||||
drawWidth: 1,
|
drawWidth: 1,
|
||||||
drawHeight: 1
|
drawHeight: 1
|
||||||
});
|
});
|
||||||
console.log(G.map[i + 1].island.name + " created at " + G.map[i + 1].island.x + ", " + G.map[i + 1].island.y);
|
// console.log(G.map[i + 1].island.name + " created at " + G.map[i + 1].island.x + ", " + G.map[i + 1].island.y);
|
||||||
}
|
}
|
||||||
|
console.log(xSquares + "\n" + ySquares);
|
||||||
}
|
}
|
||||||
|
|
1
start.js
1
start.js
|
@ -1,6 +1,7 @@
|
||||||
OS.S.defaultStep = 1 / 120;
|
OS.S.defaultStep = 1 / 120;
|
||||||
OS.S.numberOfScriptsToLoad = 14; // Excludes the titleScreen.js room, which is not loaded yet.
|
OS.S.numberOfScriptsToLoad = 14; // Excludes the titleScreen.js room, which is not loaded yet.
|
||||||
OS.S.pixelScale = 4;
|
OS.S.pixelScale = 4;
|
||||||
|
// Oversimplified.DEBUG.showMessages = false;
|
||||||
OS.SetCamera({
|
OS.SetCamera({
|
||||||
width: pixel(64),
|
width: pixel(64),
|
||||||
height: pixel(64),
|
height: pixel(64),
|
||||||
|
|
Loading…
Reference in New Issue