Panorama moving speed idk

This commit is contained in:
DepressedTWM 2026-07-28 13:36:31 +04:00
parent cbd883dc6a
commit aba907493a
2 changed files with 65 additions and 2 deletions

View file

@ -21,6 +21,9 @@ class Game_System
attr_accessor :save_count # save count
attr_accessor :magic_number # magic number
attr_accessor :playing_bgm
# https://save-point.org/printthread.php?tid=2759
attr_accessor :autoscroll_x_speed # panorama horizontal speed
attr_accessor :autoscroll_y_speed # panorama vertical speed
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
@ -35,7 +38,8 @@ class Game_System
@message_frame = 0
@save_count = 0
@magic_number = 0
RPG::Mod.exec_hooks("hooks/Game_System/init", binding)
@autoscroll_x_speed = 0
@autoscroll_y_speed = 0
end
#--------------------------------------------------------------------------
# * Play Background Music

View file

@ -19,6 +19,13 @@ class Spriteset_Map
@viewport_lights = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport_flash = Viewport.new(0, 0, Graphics.width, Graphics.height)
@scroll_point_x = 0
@scroll_point_y = 0
@scroll_frames_x = 0
@scroll_frames_y = 0
@scroll_speed_x = $game_system.autoscroll_x_speed || 0
@scroll_speed_y = $game_system.autoscroll_y_speed || 0
@update_connection = Graphics.viewport_resized do |w, h|
@viewport.rect.width = w
@viewport.rect.height = h
@ -174,6 +181,15 @@ class Spriteset_Map
# * Frame Update
#--------------------------------------------------------------------------
def update
# https://save-point.org/printthread.php?tid=2759
# Apply new scroll speed from $game_system
if $game_system.autoscroll_x_speed != @scroll_speed_x
@scroll_speed_x = $game_system.autoscroll_x_speed
end
if $game_system.autoscroll_y_speed != @scroll_speed_y
@scroll_speed_y = $game_system.autoscroll_y_speed
end
# Update tilemap
@tilemap.wrapping = $game_map.wrapping
# If panorama is different from current one
@ -379,6 +395,20 @@ class Spriteset_Map
@viewport.update
@viewport_flash.update
@viewport_lights.update
scroll
# Update panorama plane
if $game_system.autoscroll_x_speed == 0
if $game_system.autoscroll_y_speed == 0
@panorama.ox = $game_map.display_x / 8
@panorama.oy = $game_map.display_y / 8
end
end
a = $game_system.autoscroll_x_speed != 0
b = $game_system.autoscroll_y_speed != 0
if a or b
@panorama.ox = @scroll_point_x
@panorama.oy = @scroll_point_y
end
end
#--------------------------------------------------------------------------
# * Misc operations
@ -398,5 +428,34 @@ class Spriteset_Map
footprint.correctY(y)
end
end
end
def scroll
return if @panorama.nil? || @panorama.bitmap.nil?
@scroll_speed_x ||= 0
@scroll_speed_y ||= 0
w = @panorama.bitmap.width
h = @panorama.bitmap.height
@scroll_frames_x += @scroll_speed_x
@scroll_frames_y += @scroll_speed_y
while @scroll_frames_x >= 8
@scroll_frames_x -= 8
@scroll_point_x += 1
end
while @scroll_frames_x <= -8
@scroll_frames_x += 8
@scroll_point_x -= 1
end
while @scroll_frames_y >= 8
@scroll_frames_y -= 8
@scroll_point_y += 1
end
while @scroll_frames_y <= -8
@scroll_frames_y += 8
@scroll_point_y -= 1
end
@scroll_point_x -= w if @scroll_point_x > w
@scroll_point_x += w if @scroll_point_x < -w
@scroll_point_y -= h if @scroll_point_y > h
@scroll_point_y += h if @scroll_point_y < -h
end
end