Added seamless transitions on the map, shrank Ocean room to allow making an in-game map.

This commit is contained in:
Robbie Antenesse 2016-04-07 12:26:36 -06:00
parent 8694b5412b
commit 3719e69ba3
3 changed files with 33 additions and 5 deletions

View file

@ -1,8 +1,8 @@
// var rm_TitleScreen = OS.R.Add("Default"); // var rm_TitleScreen = OS.R.Add("Default");
// var rm_Ocean = OS.R.Add("Ocean", { // var rm_Ocean = OS.R.Add("Ocean", {
var rm_Ocean = OS.R.Add("Default", { var rm_Ocean = OS.R.Add("Default", {
width: 64 * 1000 * OS.S.pixelScale, width: (64 * OS.S.pixelScale) * 64, //32 64x64 squares for the map.
height: 64 * 1000 * OS.S.pixelScale, height: (64 * OS.S.pixelScale) * 64,
backgroundColor: "#1b2632" backgroundColor: "#1b2632"
}); });

View file

@ -45,6 +45,9 @@ pr_ship.Do = function () {
} else { } else {
this.doTakeStep = false; this.doTakeStep = false;
} }
this.SeamlessScroll();
console.log(G.player.name + " created at " + G.player.x + ", " + G.player.y);
} }
pr_ship.AfterDo = function () { pr_ship.AfterDo = function () {
@ -91,3 +94,22 @@ pr_ship.CheckMovement = function () {
break; 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});
}
}

View file

@ -18,15 +18,21 @@ rm_Ocean.speedGaugeImg = new Image();
rm_Ocean.speedGaugeImg.src = "images/speed_gauge_sheet.png"; rm_Ocean.speedGaugeImg.src = "images/speed_gauge_sheet.png";
rm_Ocean.DoFirst = function () { 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 // Reset camera whenever room starts
OS.SetCamera({ OS.SetCamera({
x: G.player.x - (OS.camera.width / 2), x: G.player.x - (OS.camera.width / 2),
y: G.player.y - (OS.camera.height / 2), y: G.player.y - (OS.camera.height / 2),
objectToFollow: G.player 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 () { rm_Ocean.Do = function () {
// Move G.oceanParticle around based on player's movement. // Move G.oceanParticle around based on player's movement.