From 697ff6f97745b271a5137bc794e839e38fe68f6c Mon Sep 17 00:00:00 2001 From: Issac332 <119879937+Issac8658@users.noreply.github.com> Date: Thu, 16 Jul 2026 22:07:34 +0300 Subject: [PATCH] some map features --- scripts/Game_Map.rb | 46 ++++++++++++++++++++++++++++++++++++++++++ scripts/Scene_Title.rb | 6 +++--- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/scripts/Game_Map.rb b/scripts/Game_Map.rb index 6e38592..faf2f94 100644 --- a/scripts/Game_Map.rb +++ b/scripts/Game_Map.rb @@ -23,6 +23,12 @@ class Game_Map attr_accessor :battleback_name # battleback file name attr_accessor :display_x # display x-coordinate * 128 attr_accessor :display_y # display y-coordinate * 128 + attr_accessor :display_clip_bottom + attr_accessor :display_clip_left + attr_accessor :display_clip_right + attr_accessor :display_clip_top + attr_accessor :display_x_fix + attr_accessor :display_y_fix attr_accessor :wrap_x # display x-coordinate * 128 for wrap attr_accessor :wrap_y # display y-coordinate * 128 for wrap attr_accessor :need_refresh # refresh request flag @@ -83,6 +89,12 @@ class Game_Map @map_id = 0 @display_x = 0 @display_y = 0 + @display_clip_bottom = 999999 + @display_clip_left = 0 + @display_clip_right = 999999 + @display_clip_top = 0 + @display_x_fix = nil + @display_y_fix = nil end #-------------------------------------------------------------------------- # * Setup @@ -118,6 +130,12 @@ class Game_Map # Initialize displayed coordinates @display_x = 0 @display_y = 0 + @display_clip_bottom = 999999 + @display_clip_left = 0 + @display_clip_right = 999999 + @display_clip_top = 0 + @display_x_fix = nil + @display_y_fix = nil @wrap_x = 0 @wrap_y = 0 # Clear refresh request flag @@ -263,36 +281,48 @@ class Game_Map # distance : scroll distance #-------------------------------------------------------------------------- def scroll_down(distance) + return if @display_y_fix + if self.height < Graphics.height / 28 @display_y = self.height / 2 else @display_y = [@display_y + distance, (self.height - Graphics.height / 28) * 128].min end + @display_y = @display_y.clamp((@display_clip_top * 128.0).to_i, (@display_clip_bottom * 128.0).to_i - Graphics.height * 4) end #-------------------------------------------------------------------------- # * Scroll Left # distance : scroll distance #-------------------------------------------------------------------------- def scroll_left(distance) + return if @display_x_fix + @display_x = [@display_x - distance, 0].max + @display_x = @display_x.clamp((@display_clip_left * 128.0).to_i, (@display_clip_right * 128.0).to_i - Graphics.width * 4) end #-------------------------------------------------------------------------- # * Scroll Right # distance : scroll distance #-------------------------------------------------------------------------- def scroll_right(distance) + return if @display_x_fix + @display_x = [@display_x + distance, (self.width - (Graphics.width / 32)) * 128].min + @display_x = @display_x.clamp((@display_clip_left * 128.0).to_i, (@display_clip_right * 128.0).to_i - Graphics.width * 4) end #-------------------------------------------------------------------------- # * Scroll Up # distance : scroll distance #-------------------------------------------------------------------------- def scroll_up(distance) + return if @display_y_fix + if self.height < Graphics.height / 28 @display_y = self.height / 2 else @display_y = [@display_y - distance, 0].max end + @display_y = @display_y.clamp((@display_clip_top * 128.0).to_i, (@display_clip_bottom * 128.0).to_i - Graphics.height * 4) end #-------------------------------------------------------------------------- # * Determine Valid Coordinates @@ -486,6 +516,11 @@ class Game_Map # * Frame Update #-------------------------------------------------------------------------- def update + @display_clip_top = @display_clip_top || 0 + @display_clip_left = @display_clip_left || 0 + @display_clip_right = @display_clip_right || 999999 + @display_clip_bottom = @display_clip_bottom || 999999 + # Refresh map if necessary if $game_map.need_refresh refresh @@ -535,6 +570,17 @@ class Game_Map @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d @fog_opacity_duration -= 1 end + + if @display_x_fix + @display_x = (@display_x_fix * 128.0).to_i - Graphics.width * 2 + else + @display_x = @display_x.clamp((@display_clip_left * 128.0).to_i, (@display_clip_right * 128.0).to_i - Graphics.width * 4) + end + if @display_y_fix + @display_y = (@display_y_fix * 128.0).to_i - Graphics.height * 2 + else + @display_y = @display_y.clamp((@display_clip_top * 128.0).to_i, (@display_clip_bottom * 128.0).to_i - Graphics.height * 4) + end end def set_tile(x, y, z, tile) diff --git a/scripts/Scene_Title.rb b/scripts/Scene_Title.rb index 877e4ee..caea9ec 100644 --- a/scripts/Scene_Title.rb +++ b/scripts/Scene_Title.rb @@ -115,7 +115,7 @@ class Scene_Title @cursor.zoom_x = @cursor.zoom_y = 2 @cursor.z += 2 @cursor.x = Graphics.width - MENU_X - 12 - @cursor.y = Graphics.height - MENU_Y + (ENTRY_HEIGHT - @cursor.bitmap.height) / 2 - 2 + @cursor.y = Graphics.height - MENU_Y + (ENTRY_HEIGHT - @cursor.bitmap.height) / 2 - 3 # Initialize cursor position @cursor_pos = 0.0 @@ -127,7 +127,7 @@ class Scene_Title @menu.x = w - MENU_X @menu.y = h - MENU_Y @cursor.x = w - MENU_X - 12 - @cursor.y = ((h - MENU_Y).to_f + (ENTRY_HEIGHT - @cursor.bitmap.height) / 2.0 + ENTRY_HEIGHT * @cursor_pos - 2) + @cursor.y = ((h - MENU_Y).to_f + (ENTRY_HEIGHT - @cursor.bitmap.height) / 2.0 + ENTRY_HEIGHT * @cursor_pos - 3) @sprite.x = w / 2 @sprite.y = h / 2 @@ -198,7 +198,7 @@ class Scene_Title # Handle cursor movement if !@window_settings_title.visible - @cursor.y = ((Graphics.height - MENU_Y).to_f + (ENTRY_HEIGHT - @cursor.bitmap.height) / 2.0 + ENTRY_HEIGHT * @cursor_pos - 2) * 0.65 + @cursor.y.to_f * 0.35 + @cursor.y = ((Graphics.height - MENU_Y).to_f + (ENTRY_HEIGHT - @cursor.bitmap.height) / 2.0 + ENTRY_HEIGHT * @cursor_pos - 3) * 0.65 + @cursor.y.to_f * 0.35 update_cursor = false if Input.trigger?(Input::UP) if @cursor_pos > 0