VXAce Offset camera position

Hey everyone,

I'm making a PC98 style RPG. Games from that era made use of a UI that covers a large portion of the screen. I want to have this UI on screen and be able to offset the camera so that the player character stays in the center of the game window. Is this something that can be achieved in RPG Maker VXAce?

I'd like to move the camera itself rather than the player character

Pasted image (2).png
Heyo,

I played around a bit, and it seems to boil down to having to redefine what is the center for the Game_Player and the Game_Map classes. That way you can define a "smaller" screen, however, the potential offset from the upper left corner is harder to modify, unless you change the viewport creation in Spriteset_Mapwhich is what I did here.
Here is my script, you can modify the constants in module CameraOffset to suit your need.
I don't know how your menu is handled but if you use pictures, they are by default handled by viewport2 (along with the map weather) while the colorset is handled by viewport3.

So here are some possibilities:
-if you don't need the offset in x,y because your screen is on the upperleft corner, you can remove my code in Spriteset_Map.
-if you need the offset and you use pictures, then either I can try to change what is the viewport for pictures or you can replace
Ruby:
@viewport2 = Viewport.new($game_player.cam_x,$game_player.cam_y,$game_player.cam_w,$game_player.cam_h)
with @viewport2 = Viewport.new.
-if you script windows or something else, then I suppose the viewport feature can work.

Also not that as I mess with viewports, the script here won't be compatible with Yanfly's Core Engine.

Ruby:
module CameraOffset
  X = 10 #offset in pixels
  Y = 0 #offset in pixels
  WIDTH = Graphics.width - 100 #window's width in pixels
  HEIGHT = Graphics.height - 40 #window's height in pixels
  
  TILE_SIZE = 32.0 #a constant to not modify
end #CamCenter

#============================================================================
# Game_Player
#============================================================================
class Game_Player
  #you can modify these values mid game but you'll have to refresh the scene
  attr_accessor :cam_x, :cam_y, :cam_w, :cam_h
  #--------------------------------------------------------------------------
  # alias method: initialize
  #--------------------------------------------------------------------------
  alias tim_camera_initialize initialize
  def initialize
    tim_camera_initialize
    @cam_x = CameraOffset::X
    @cam_y = CameraOffset::Y
    @cam_w = CameraOffset::WIDTH
    @cam_h = CameraOffset::HEIGHT
  end
  #--------------------------------------------------------------------------
  # overwrite method: center_x
  #--------------------------------------------------------------------------
  def center_x
    ((@cam_w) / CameraOffset::TILE_SIZE - 1) / 2.0
  end
  #--------------------------------------------------------------------------
  # overwrite method: center_y
  #--------------------------------------------------------------------------
  def center_y
    ((@cam_h) / CameraOffset::TILE_SIZE - 1) / 2.0
  end
end #Game_Player

#============================================================================
# Game_Map
#============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # overwrite method: screen_tile_x
  #--------------------------------------------------------------------------
  def screen_tile_x
    $game_player.cam_w / CameraOffset::TILE_SIZE
  end
  #--------------------------------------------------------------------------
  # overwrite method: screen_tile_y
  #--------------------------------------------------------------------------
  def screen_tile_y
    $game_player.cam_h / CameraOffset::TILE_SIZE
  end
end #Game_Map

#============================================================================
# Spriteset_Map
#============================================================================
class Spriteset_Map
  #--------------------------------------------------------------------------
  # overwrite method: create_viewports
  #--------------------------------------------------------------------------
  def create_viewports
    @viewport1 = Viewport.new($game_player.cam_x,$game_player.cam_y,$game_player.cam_w,$game_player.cam_h)
    @viewport2 = Viewport.new($game_player.cam_x,$game_player.cam_y,$game_player.cam_w,$game_player.cam_h)
    @viewport3 = Viewport.new($game_player.cam_x,$game_player.cam_y,$game_player.cam_w,$game_player.cam_h)
    @viewport2.z = 50
    @viewport3.z = 100
  end
end #Spriteset_Map

Here is what it looks like:
1758842724783.png


And.. voilà, feel free to ask questions or suggestions. Displaying stuff is not my forte so hopefully other people will be able to help you too.

Original thread: https://forums.rpgmakerweb.com/threads/offset-camera-position.180271/