diff --git a/loadRooms.js b/loadRooms.js index 192ca00..4702488 100644 --- a/loadRooms.js +++ b/loadRooms.js @@ -1,8 +1,8 @@ // var rm_TitleScreen = OS.R.Add("Default"); // var rm_Ocean = OS.R.Add("Ocean", { var rm_Ocean = OS.R.Add("Default", { - width: 64 * 1000 * OS.S.pixelScale, - height: 64 * 1000 * OS.S.pixelScale, + width: (64 * OS.S.pixelScale) * 64, //32 64x64 squares for the map. + height: (64 * OS.S.pixelScale) * 64, backgroundColor: "#1b2632" }); diff --git a/prefabs/shipPrefab.js b/prefabs/shipPrefab.js index cc7e66f..99efffd 100644 --- a/prefabs/shipPrefab.js +++ b/prefabs/shipPrefab.js @@ -45,6 +45,9 @@ pr_ship.Do = function () { } else { this.doTakeStep = false; } + + this.SeamlessScroll(); + console.log(G.player.name + " created at " + G.player.x + ", " + G.player.y); } pr_ship.AfterDo = function () { @@ -91,3 +94,22 @@ pr_ship.CheckMovement = function () { break; } } + +pr_ship.SeamlessScroll = function () { + if (this.x <= rm_Ocean.mapLeftTrigger) { + this.x = rm_Ocean.mapLeftTriggerTarget; + OS.SetCamera({x: rm_Ocean.width}); + } + else if (this.x >= rm_Ocean.mapRightTrigger) { + this.x = rm_Ocean.mapRightTriggerTarget; + OS.SetCamera({x: 0}); + } + else if (this.y <= rm_Ocean.mapUpTrigger) { + this.y = rm_Ocean.mapUpTriggerTarget; + OS.SetCamera({y: rm_Ocean.height}); + } + else if (this.y >= rm_Ocean.mapDownTrigger) { + this.y = rm_Ocean.mapDownTriggerTarget; + OS.SetCamera({y: 0}); + } +} diff --git a/rooms/oceanRoom.js b/rooms/oceanRoom.js index 2e95aab..f63ecdc 100644 --- a/rooms/oceanRoom.js +++ b/rooms/oceanRoom.js @@ -18,15 +18,21 @@ rm_Ocean.speedGaugeImg = new Image(); rm_Ocean.speedGaugeImg.src = "images/speed_gauge_sheet.png"; rm_Ocean.DoFirst = function () { - //Hide cursor when playing (only use if masking the cursor with another object) - //OS.canvas.style.cursor = "none"; - // Reset camera whenever room starts OS.SetCamera({ x: G.player.x - (OS.camera.width / 2), y: G.player.y - (OS.camera.height / 2), objectToFollow: G.player }); + + this.mapLeftTrigger = OS.camera.hBorder; + this.mapLeftTriggerTarget = this.width - (OS.camera.width - OS.camera.hBorder); + this.mapRightTrigger = this.width - OS.camera.hBorder; + this.mapRightTriggerTarget = OS.camera.width - OS.camera.hBorder; + this.mapUpTrigger = OS.camera.vBorder; + this.mapUpTriggerTarget = this.height - (OS.camera.height - OS.camera.vBorder); + this.mapDownTrigger = this.height - OS.camera.vBorder; + this.mapDownTriggerTarget = OS.camera.height - OS.camera.vBorder; } rm_Ocean.Do = function () { // Move G.oceanParticle around based on player's movement.