Game_Player.prototype.centerY = function() {
var y =(Graphics.height / $gameMap.tileHeight() - 1) / 2.0;
y += 1;
return y;
return (Graphics.height / $gameMap.tileHeight() - 1 + 3) / 2.0;
};
Game_Map.prototype.setDisplayPos = function(x, y) {
//y += 3;
if (this.isLoopHorizontal()) {
this._displayX = x.mod(this.width());
this._parallaxX = x;
} else {
var endX = this.width() - this.screenTileX();
this._displayX = endX < 0 ? endX / 2 : x.clamp(0, endX);
this._parallaxX = this._displayX;
}
if (this.isLoopVertical()) {
this._displayY = y.mod(this.height());
this._parallaxY = y;
} else {
var endY = this.height() - this.screenTileY();
this._displayY = endY < 0 ? endY / 2 : y.clamp(0, endY);
//this._displayY += 6;
this._parallaxY = this._displayY;
}
};
Game_Player.prototype.updateScroll = function(lastScrolledX, lastScrolledY) {
var x1 = lastScrolledX;
var y1 = lastScrolledY;
var x2 = this.scrolledX();
var y2 = this.scrolledY();
if (y2 > y1 && y2 > this.centerY()) {
$gameMap.scrollDown(y2 - y1);
}
if (x2 < x1 && x2 < this.centerX()) {
$gameMap.scrollLeft(x1 - x2);
}
if (x2 > x1 && x2 > this.centerX()) {
$gameMap.scrollRight(x2 - x1);
}
if (y2 < y1 && y2 < this.centerY()) {
$gameMap.scrollUp(y1 - y2);
}
};
Game_Map.prototype.scrollDown = function(distance) {
if (this.isLoopVertical()) {
this._displayY += distance;
this._displayY %= $dataMap.height;
if (this._parallaxLoopY) {
this._parallaxY += distance;
}
} else if (this.height() >= this.screenTileY()) {
var lastY = this._displayY;
this._displayY = Math.min(this._displayY + distance,
this.height() - this.screenTileY());
this._parallaxY += this._displayY - lastY;
}
};
Game_Map.prototype.scrollLeft = function(distance) {
if (this.isLoopHorizontal()) {
this._displayX += $dataMap.width - distance;
this._displayX %= $dataMap.width;
if (this._parallaxLoopX) {
this._parallaxX -= distance;
}
} else if (this.width() >= this.screenTileX()) {
var lastX = this._displayX;
this._displayX = Math.max(this._displayX - distance, 0);
this._parallaxX += this._displayX - lastX;
}
};
Game_Map.prototype.scrollRight = function(distance) {
if (this.isLoopHorizontal()) {
this._displayX += distance;
this._displayX %= $dataMap.width;
if (this._parallaxLoopX) {
this._parallaxX += distance;
}
} else if (this.width() >= this.screenTileX()) {
var lastX = this._displayX;
this._displayX = Math.min(this._displayX + distance,
this.width() - this.screenTileX());
this._parallaxX += this._displayX - lastX;
}
};
Game_Map.prototype.scrollUp = function(distance) {
if (this.isLoopVertical()) {
this._displayY += $dataMap.height - distance;
this._displayY %= $dataMap.height;
if (this._parallaxLoopY) {
this._parallaxY -= distance;
}
} else if (this.height() >= this.screenTileY()) {
var lastY = this._displayY;
this._displayY = Math.max(this._displayY - distance, 0);
this._parallaxY += this._displayY - lastY;
}
};