diff --git a/loadControls.js b/loadControls.js index 7f0cc86..0aa90f3 100644 --- a/loadControls.js +++ b/loadControls.js @@ -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_z = OS.C.Add("Z", OS.Keycode.z); 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); function loadControls () {} diff --git a/prefabs/islandPrefab.js b/prefabs/islandPrefab.js index dd5d919..56f8670 100644 --- a/prefabs/islandPrefab.js +++ b/prefabs/islandPrefab.js @@ -6,6 +6,7 @@ var pr_island = OS.P.Add("Island", { solid: true, imageSrc: "images/island.png", animations: [ani_island_1], + depth: -50, mapX: 0, mapY: 0, diff --git a/prefabs/shipPrefab.js b/prefabs/shipPrefab.js index c7c2b1e..e5f5ee5 100644 --- a/prefabs/shipPrefab.js +++ b/prefabs/shipPrefab.js @@ -74,7 +74,7 @@ pr_ship.AfterDo = function () { pr_ship.GetMapPosition = function () { this.mapX = pixel(Math.round(this.x / 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 () { diff --git a/rooms/oceanRoom.js b/rooms/oceanRoom.js index dedcbe5..ccbd1f1 100644 --- a/rooms/oceanRoom.js +++ b/rooms/oceanRoom.js @@ -59,12 +59,16 @@ rm_Ocean.Do = function () { 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 (ct_cancel().down) { guiControl.inventory.activateDelay = 5; 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 () { - var island1 = rm_Ocean.AddObject(OS.P["Island"], { - x: pixel(64) * 25, //Exact center of map. - y: pixel(64) * 22 - }); - - console.log(island1.name + " created at " + island1.x + ", " + island1.y); - G.map.push({ - island: island1, - drawX: 25, - drawY: 22, - drawWidth: 1, - drawHeight: 1 - }); + var xSquares = [25]; + var ySquares = [22]; - 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)); + while(xSquares.length < 10){ + var randomX = Math.round(Math.randomRange(1, 48)); + var foundX = false; + for(var i = 0; i < xSquares.length; i++){ + // console.log(i + ": " + (xSquares[i] - 3) + " <= " + randomX + " <= " + (xSquares[i] + 3) + "?"); + if (randomX >= xSquares[i] - 3 && randomX <= xSquares[i] + 3) { + foundX = true; + break; + } } - 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)); + if (!foundX) xSquares[xSquares.length] = randomX; + } + while(ySquares.length < 10){ + 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; + } } - usedYSquares.push(ySquare); + if (!foundY) ySquares[ySquares.length] = randomY; + } - var xPosition = pixel(64) * xSquare; - var yPosition = pixel(64) * ySquare; - + for (var i = 0; i < xSquares.length; i++) { G.map.push({ island: rm_Ocean.AddObject(OS.P["Island"], { - x: xPosition, - y: yPosition + x: pixel(64) * xSquares[i], + y: pixel(64) * ySquares[i] }), - drawX: xSquare, - drawY: ySquare, + drawX: xSquares[i], + drawY: ySquares[i], drawWidth: 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); } diff --git a/start.js b/start.js index e5d79b9..d4f9fae 100644 --- a/start.js +++ b/start.js @@ -1,6 +1,7 @@ OS.S.defaultStep = 1 / 120; OS.S.numberOfScriptsToLoad = 14; // Excludes the titleScreen.js room, which is not loaded yet. OS.S.pixelScale = 4; +// Oversimplified.DEBUG.showMessages = false; OS.SetCamera({ width: pixel(64), height: pixel(64),