More FPS agnosticism, fixed pause after finishing an event's repeating move route

This commit is contained in:
Maruno17
2023-05-24 21:20:20 +01:00
parent 167155c67d
commit c756e2647a
30 changed files with 947 additions and 847 deletions

View File

@@ -15,37 +15,46 @@ class Game_Screen
attr_accessor :weather_duration # ticks in which the weather should fade in
def initialize
@brightness = 255
@fadeout_duration = 0
@fadein_duration = 0
@tone = Tone.new(0, 0, 0, 0)
@tone_target = Tone.new(0, 0, 0, 0)
@tone_duration = 0
@flash_color = Color.new(0, 0, 0, 0)
@flash_duration = 0
@shake_power = 0
@shake_speed = 0
@shake_duration = 0
@shake_direction = 1
@shake = 0
@pictures = [nil]
(1..100).each do |i|
@pictures.push(Game_Picture.new(i))
end
@weather_type = :None
@weather_max = 0.0
@weather_duration = 0
@brightness = 255
@fadeout_duration = 0
@fadein_duration = 0
@tone = Tone.new(0, 0, 0, 0)
@tone_target = Tone.new(0, 0, 0, 0)
@tone_duration = 0
@tone_timer_start = nil
@flash_color = Color.new(0, 0, 0, 0)
@flash_duration = 0
@flash_timer_start = nil
@shake_power = 0
@shake_speed = 0
@shake_duration = 0
@shake_direction = 1
@shake = 0
@pictures = [nil]
(1..100).each { |i| @pictures.push(Game_Picture.new(i)) }
@weather_type = :None
@weather_max = 0.0
@weather_duration = 0
end
# duration is time in 1/20ths of a second.
def start_tone_change(tone, duration)
@tone_target = tone.clone
@tone_duration = duration
@tone = @tone_target.clone if @tone_duration == 0
if duration == 0
@tone = tone.clone
return
end
@tone_initial = @tone.clone
@tone_target = tone.clone
@tone_duration = duration / 20.0
@tone_timer_start = $stats.play_time
end
# duration is time in 1/20ths of a second.
def start_flash(color, duration)
@flash_color = color.clone
@flash_duration = duration
@flash_color = color.clone
@flash_initial_alpha = @flash_color.alpha
@flash_duration = duration / 20.0
@flash_timer_start = $stats.play_time
end
def start_shake(power, speed, duration)
@@ -71,18 +80,23 @@ class Game_Screen
@brightness = ((@brightness * (d - 1)) + 255) / d
@fadein_duration -= 1
end
if @tone_duration >= 1
d = @tone_duration
@tone.red = ((@tone.red * (d - 1)) + @tone_target.red) / d
@tone.green = ((@tone.green * (d - 1)) + @tone_target.green) / d
@tone.blue = ((@tone.blue * (d - 1)) + @tone_target.blue) / d
@tone.gray = ((@tone.gray * (d - 1)) + @tone_target.gray) / d
@tone_duration -= 1
now = $stats.play_time
if @tone_timer_start
@tone.red = lerp(@tone_initial.red, @tone_target.red, @tone_duration, @tone_timer_start, now)
@tone.green = lerp(@tone_initial.green, @tone_target.green, @tone_duration, @tone_timer_start, now)
@tone.blue = lerp(@tone_initial.blue, @tone_target.blue, @tone_duration, @tone_timer_start, now)
@tone.gray = lerp(@tone_initial.gray, @tone_target.gray, @tone_duration, @tone_timer_start, now)
if now - @tone_timer_start >= @tone_duration
@tone_initial = nil
@tone_timer_start = nil
end
end
if @flash_duration >= 1
d = @flash_duration
@flash_color.alpha = @flash_color.alpha * (d - 1) / d
@flash_duration -= 1
if @flash_timer_start
@flash_color.alpha = lerp(@flash_initial_alpha, 0, @flash_duration, @flash_timer_start, now)
if now - @flash_timer_start >= @flash_duration
@flash_initial_alpha = nil
@flash_timer_start = nil
end
end
if @shake_duration >= 1 || @shake != 0
delta = (@shake_power * @shake_speed * @shake_direction) / 10.0
@@ -96,13 +110,9 @@ class Game_Screen
@shake_duration -= 1 if @shake_duration >= 1
end
if $game_temp.in_battle
(51..100).each do |i|
@pictures[i].update
end
(51..100).each { |i| @pictures[i].update }
else
(1..50).each do |i|
@pictures[i].update
end
(1..50).each { |i| @pictures[i].update }
end
end
end
@@ -111,16 +121,14 @@ end
#
#===============================================================================
def pbToneChangeAll(tone, duration)
$game_screen.start_tone_change(tone, duration * Graphics.frame_rate / 20)
$game_screen.pictures.each do |picture|
picture&.start_tone_change(tone, duration * Graphics.frame_rate / 20)
end
$game_screen.start_tone_change(tone, duration)
$game_screen.pictures.each { |picture| picture&.start_tone_change(tone, duration) }
end
def pbFlash(color, frames)
$game_screen.start_flash(color, frames)
end
def pbShake(power, speed, frames)
$game_screen.start_shake(power, speed, frames * Graphics.frame_rate / 20)
end
def pbFlash(color, frames)
$game_screen.start_flash(color, frames * Graphics.frame_rate / 20)
end