RPG Maker Forums

Hi
I'm working on side scrolling game
and the Rpg Maker camera always lock to the center
I want make the camera adjust by player facing
right is -3 tile etc
and go make a shot in this

Code:
Game_Player.prototype.centerX = function() {
  var x = (Graphics.width / $gameMap.tileWidth() - 1) / 2.0;
  var d = this.direction();
  var i = 3;
  if(d === 4){
    x += i;
  }
  if(d === 6){
    x -= i;
  }
  return x;
};
but turn out it work only in negative way
like when face right the camera will shift to the left
image_20200227_103901.png
it's opposite of what I want
(the guy in picture suppose to stand on the left instead)
when I try to change the +/- sequence
another outcome just doesn't change anything and lock the character to center like default

So...
I try around on those

Code:
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;
  }
};
but can't find a good outcome too

thank you

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,017
Messages
1,018,356
Members
137,802
Latest member
rencarbali
Top