I want the camera to vertically show always more screen in the player-faced direction.
UPDATE 1:
UPDATE 2:
I achieved it! No exactly what I want but it works quite well.
Thanks in advance.
This code achieves it, but the camera now ugly jumps when the player changes their direction. Can this effect be achieved with an scroll-smooth camera movement?
JavaScript:
var oldy=0;
var _GamePlayer_centerY = Game_Player.prototype.centerY;
Game_Player.prototype.centerY = function() {
if(this._direction==2 && oldy!=-3){
oldy=-3;
this.center(this.x,this.y);
}else if(this._direction==8 && oldy!=3){
oldy=3;
this.center(this.x,this.y);
}
return _GamePlayer_centerY.call(this) + oldy;
};
UPDATE 1:
I achieved it! But i'm sure that there are some calculations bad, as in some cases the camera scrolls when it shouldn't. I believe that there is a bug in sc_tileoverplayer, sc_tileunderplayer or sc_center. Any clue?
JavaScript:
var sc_oldmarg=0,sc_distance=0,sc_speed=0,sc_center=0,sc_zoom=0;
Game_Player.prototype.centerY = function() {
sc_zoom=1;
sc_distance=(sc_zoom==1)?2:1;
sc_speed=4;
sc_center=($gameMap.screenTileY()/sc_zoom)/2;
var sc_tileoverplayer=(this.y-$gameMap._displayY);
var sc_tileunderplayer=(($gameMap._displayY+$gameMap.screenTileY())-this.y-1);
if(this._direction==2 && sc_oldmarg!=-sc_distance){
sc_oldmarg=-sc_distance;
// console.log("2 | "+sc_tileoverplayer+" > "+(sc_center-sc_distance));
if(sc_tileoverplayer>sc_center-sc_distance && !$gameMap.isScrolling()){
$gameMap.startScroll(this._direction, sc_distance*2, sc_speed);
}
}else if(this._direction==8 && sc_oldmarg!=sc_distance){
sc_oldmarg=sc_distance;
// console.log("8 | "+sc_tileunderplayer+" > "+(sc_center-sc_distance));
if(sc_tileunderplayer>sc_center-sc_distance && !$gameMap.isScrolling()){
$gameMap.startScroll(this._direction, sc_distance*2, sc_speed);
}
}
return (_GamePlayer_centerY.call(this)/sc_zoom)+sc_oldmarg;
};
UPDATE 2:
I achieved it! No exactly what I want but it works quite well.
JavaScript:
var sc_oldmarg=0;
Game_Player.prototype.centerY = function() {
var sc_zoom=1, sc_distance=1, sc_speed=(sc_zoom==1)?5:4;
if(sc_oldmarg==0){
sc_oldmarg=(this._direction==2)?(-1*sc_distance):sc_distance;
}
if(this._direction==2){
if(sc_oldmarg!=-1*sc_distance){
sc_oldmarg=-1*sc_distance;
$gameMap.startScroll(this._direction, sc_distance*2, sc_speed);
}
}else if(this._direction==8){
if(sc_oldmarg!=sc_distance){
sc_oldmarg=sc_distance;
$gameMap.startScroll(this._direction, sc_distance*2, sc_speed);
}
}
return (_GamePlayer_centerY.call(this)/sc_zoom)+sc_oldmarg;
};
Thanks in advance.