Removed Graphics.delta_s and the usage thereof, tweaked credits screen code

This commit is contained in:
Maruno17
2023-05-17 18:50:38 +01:00
parent a96867d537
commit 28a2b7c9c1
17 changed files with 195 additions and 210 deletions

View File

@@ -64,8 +64,8 @@ def pbPrintException(e)
# output message
print("#{message}\r\nThis exception was logged in #{errorlogline}.\r\nHold Ctrl when closing this message to copy it to the clipboard.")
# Give a ~500ms coyote time to start holding Control
t = System.delta
until (System.delta - t) >= 500_000
t = System.uptime
until System.uptime - t >= 0.5
Input.update
if Input.press?(Input::CTRL)
Input.clipboard = message

View File

@@ -27,12 +27,6 @@ class Bitmap
end
end
module Graphics
def self.delta_s
return self.delta
end
end
def pbSetResizeFactor(factor)
if !$ResizeInitialized
Graphics.resize_screen(Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT)

View File

@@ -395,8 +395,8 @@ module PluginManager
# output message
print("#{message}\r\nThis exception was logged in #{errorlogline}.\r\nHold Ctrl when closing this message to copy it to the clipboard.")
# Give a ~500ms coyote time to start holding Control
t = System.delta
until (System.delta - t) >= 500_000
t = System.uptime
until System.uptime - t >= 0.5
Input.update
if Input.press?(Input::CTRL)
Input.clipboard = message

View File

@@ -46,6 +46,7 @@ module Game
pbMapInterpreter&.setup(nil, 0, 0)
$scene = Scene_Map.new
SaveData.load_new_game_values
$game_temp.last_uptime_refreshed_play_time = System.uptime
$stats.play_sessions += 1
$map_factory = PokemonMapFactory.new($data_system.start_map_id)
$game_player.moveto($data_system.start_x, $data_system.start_y)
@@ -62,6 +63,7 @@ module Game
def self.load(save_data)
validate save_data => Hash
SaveData.load_all_values(save_data)
$game_temp.last_uptime_refreshed_play_time = System.uptime
$stats.play_sessions += 1
self.load_map
pbAutoplayOnSave

View File

@@ -232,6 +232,7 @@ class Scene_Map
dispose
if $game_temp.title_screen_calling
pbMapInterpreter.command_end if pbMapInterpreterRunning?
$game_temp.last_uptime_refreshed_play_time = nil
$game_temp.title_screen_calling = false
pbBGMFade(1.0)
Graphics.transition

View File

@@ -56,7 +56,7 @@ class GameStats
attr_accessor :safari_pokemon_caught, :most_captures_per_safari_game
attr_accessor :bug_contest_count, :bug_contest_wins
# Play
attr_accessor :play_time # In seconds
attr_writer :play_time # In seconds; the reader also updates the value
attr_accessor :play_sessions
attr_accessor :time_last_saved # In seconds
@@ -161,38 +161,37 @@ class GameStats
end
def set_time_to_badge(number)
@times_to_get_badges[number] = @play_time
@times_to_get_badges[number] = play_time
end
def set_time_to_hall_of_fame
@time_to_enter_hall_of_fame = @play_time if @time_to_enter_hall_of_fame == 0
@time_to_enter_hall_of_fame = play_time if @time_to_enter_hall_of_fame == 0
end
def play_time
if $game_temp&.last_uptime_refreshed_play_time
@play_time += System.uptime - $game_temp.last_uptime_refreshed_play_time
$game_temp.last_uptime_refreshed_play_time = System.uptime
end
return @play_time
end
def play_time_per_session
return @play_time / @play_sessions
return play_time / @play_sessions
end
def set_time_last_saved
@time_last_saved = @play_time
@time_last_saved = play_time
end
def time_since_last_save
return @play_time - @time_last_saved
return play_time - @time_last_saved
end
end
#===============================================================================
#
#===============================================================================
module Graphics
unless defined?(update_stats_play_time)
class << Graphics
alias update_stats_play_time update
end
end
def self.update
update_stats_play_time
$stats.play_time += self.delta_s if $stats && $PokemonEncounters
end
class Game_Temp
attr_accessor :last_uptime_refreshed_play_time
end

View File

@@ -127,7 +127,7 @@ class TilemapRenderer
@frame_counts = {} # Number of frames in each autotile
@frame_durations = {} # How long each frame lasts per autotile
@current_frames = {} # Which frame each autotile is currently showing
@timer = 0.0
@timer_start = System.uptime
end
def []=(filename, value)
@@ -193,7 +193,7 @@ class TilemapRenderer
if frames < 2
@current_frames[filename] = 0
else
@current_frames[filename] = (@timer / @frame_durations[filename]).floor % frames
@current_frames[filename] = ((System.uptime - @timer_start) / @frame_durations[filename]).floor % frames
end
end
@@ -219,7 +219,6 @@ class TilemapRenderer
def update
super
@timer += Graphics.delta_s
# Update the current frame for each autotile
@bitmaps.each_key do |filename|
next if !@bitmaps[filename] || @bitmaps[filename].disposed?

View File

@@ -114,7 +114,7 @@ module Transitions
end
@duration = self.class::DURATION || duration
@parameters = args
@timer = 0.0
@timer_start = System.uptime
@overworld_bitmap = $game_temp.background_bitmap
initialize_bitmaps
return if disposed?
@@ -138,6 +138,10 @@ module Transitions
return s
end
def timer
return System.uptime - @timer_start
end
def dispose
return if disposed?
dispose_all
@@ -153,8 +157,7 @@ module Transitions
def update
return if disposed?
@timer += Graphics.delta_s
if @timer >= @duration
if timer >= @duration
dispose
return
end
@@ -201,7 +204,7 @@ module Transitions
end
def update_anim
proportion = @timer / @duration
proportion = timer / @duration
@sprites.each_with_index do |sprite, i|
sprite.y = @start_y[i] + (Graphics.height * @timings[i] * proportion * proportion)
sprite.opacity = 255 * (1 - proportion)
@@ -232,7 +235,7 @@ module Transitions
end
def update_anim
proportion = @timer / @duration
proportion = timer / @duration
@sprites.each_with_index do |sprite, i|
sprite.zoom_x = (1 - proportion).to_f
sprite.zoom_y = sprite.zoom_x
@@ -298,7 +301,7 @@ module Transitions
end
def update_anim
proportion = @timer / @duration
proportion = timer / @duration
@sprites.each_with_index do |sprite, i|
sprite.x = @start_positions[i][0] + (@move_vectors[i][0] * proportion)
sprite.y = @start_positions[i][1] + (@move_vectors[i][1] * proportion)
@@ -353,7 +356,7 @@ module Transitions
def update_anim
@sprites.each_with_index do |sprite, i|
next if @timings[i] < 0 || @timer < @timings[i]
next if @timings[i] < 0 || timer < @timings[i]
sprite.visible = false
@timings[i] = -1
end
@@ -372,7 +375,7 @@ module Transitions
end
def update_anim
proportion = @timer / @duration
proportion = timer / @duration
@overworld_sprite.zoom_x = 1 + (7 * proportion)
@overworld_sprite.zoom_y = @overworld_sprite.zoom_x
@overworld_sprite.opacity = 255 * (1 - proportion)
@@ -384,7 +387,7 @@ module Transitions
#=============================================================================
class ScrollScreen < Transition_Base
def update_anim
proportion = @timer / @duration
proportion = timer / @duration
if (@parameters[0] % 3) != 2
@overworld_sprite.x = [1, -1, 0][@parameters[0] % 3] * Graphics.width * proportion
end
@@ -415,7 +418,7 @@ module Transitions
end
def update_anim
proportion = @timer / @duration
proportion = timer / @duration
inv_proportion = 1 / (1 + (proportion * (MAX_PIXELLATION_FACTOR - 1)))
new_size_rect = Rect.new(0, 0, @overworld_bitmap.width * inv_proportion,
@overworld_bitmap.height * inv_proportion)
@@ -425,8 +428,8 @@ module Transitions
# Take shrunken area from buffer_temp and stretch it into buffer
@overworld_bitmap.stretch_blt(Rect.new(0, 0, @overworld_bitmap.width, @overworld_bitmap.height),
@buffer_temp, new_size_rect)
if @timer >= @start_black_fade
@overworld_sprite.opacity = 255 * (1 - ((@timer - @start_black_fade) / (@duration - @start_black_fade)))
if timer >= @start_black_fade
@overworld_sprite.opacity = 255 * (1 - ((timer - @start_black_fade) / (@duration - @start_black_fade)))
end
end
end
@@ -436,7 +439,7 @@ module Transitions
#=============================================================================
class FadeToBlack < Transition_Base
def update_anim
@overworld_sprite.opacity = 255 * (1 - (@timer / @duration))
@overworld_sprite.opacity = 255 * (1 - (timer / @duration))
end
end
@@ -445,7 +448,7 @@ module Transitions
#=============================================================================
class FadeFromBlack < Transition_Base
def update_anim
@overworld_sprite.opacity = 255 * @timer / @duration
@overworld_sprite.opacity = 255 * timer / @duration
end
end
@@ -504,9 +507,9 @@ module Transitions
def update_anim
@sprites.each_with_index do |sprite, i|
next if @timings[i] < 0 || @timer < @timings[i]
next if @timings[i] < 0 || timer < @timings[i]
sprite.visible = true
sprite.zoom_x = @zoom_x_target * (@timer - @timings[i]) / TIME_TO_ZOOM
sprite.zoom_x = @zoom_x_target * (timer - @timings[i]) / TIME_TO_ZOOM
if sprite.zoom_x >= @zoom_x_target
sprite.zoom_x = @zoom_x_target
@timings[i] = -1
@@ -573,9 +576,9 @@ module Transitions
def update_anim
@sprites.each_with_index do |sprite, i|
next if @timings[i] < 0 || @timer < @timings[i]
next if @timings[i] < 0 || timer < @timings[i]
sprite.visible = true
size = (@timer - @timings[i]) / TIME_TO_ZOOM
size = (timer - @timings[i]) / TIME_TO_ZOOM
sprite.zoom_x = @zoom_x_target * size
sprite.zoom_y = @zoom_y_target * size
next if size < 1.0
@@ -644,22 +647,22 @@ module Transitions
def update_anim
# Make overworld wave strips oscillate
amplitude = MAX_WAVE_AMPLITUDE * [@timer / 0.1, 1].min # Build up to max in 0.1 seconds
amplitude = MAX_WAVE_AMPLITUDE * [timer / 0.1, 1].min # Build up to max in 0.1 seconds
@sprites.each_with_index do |sprite, i|
sprite.x = amplitude * Math.sin((@timer * WAVE_SPEED) + (i * WAVE_SPACING))
sprite.x = amplitude * Math.sin((timer * WAVE_SPEED) + (i * WAVE_SPACING))
end
# Move bubbles sprite up and oscillate side to side
@bubbles_sprite.x = (Graphics.width - @bubble_bitmap.width) / 2
@bubbles_sprite.x += MAX_BUBBLE_AMPLITUDE * Math.sin(@timer * BUBBLES_WAVE_SPEED)
@bubbles_sprite.y = Graphics.height * (1 - (@timer * 1.2))
@bubbles_sprite.x += MAX_BUBBLE_AMPLITUDE * Math.sin(timer * BUBBLES_WAVE_SPEED)
@bubbles_sprite.y = Graphics.height * (1 - (timer * 1.2))
# Move splash sprite up
if @timer >= @splash_rising_start
proportion = (@timer - @splash_rising_start) / (@duration - @splash_rising_start)
if timer >= @splash_rising_start
proportion = (timer - @splash_rising_start) / (@duration - @splash_rising_start)
@splash_sprite.y = Graphics.height * (1 - (proportion * 2))
end
# Move black sprite up
if @timer >= @black_rising_start
proportion = (@timer - @black_rising_start) / (@duration - @black_rising_start)
if timer >= @black_rising_start
proportion = (timer - @black_rising_start) / (@duration - @black_rising_start)
@black_sprite.y = Graphics.height * (1 - proportion)
end
end
@@ -718,16 +721,16 @@ module Transitions
end
def update_anim
if @timer <= @ball_roll_end
if timer <= @ball_roll_end
# Roll ball sprites across screen
proportion = @timer / @ball_roll_end
proportion = timer / @ball_roll_end
total_distance = Graphics.width + @ball_bitmap.width
@ball_sprites.each_with_index do |sprite, i|
sprite.x = @ball_start_x[i] + (((2 * i) - 1) * (total_distance * proportion))
sprite.angle = ((2 * i) - 1) * 360 * proportion * 2
end
else
proportion = (@timer - @ball_roll_end) / (@duration - @ball_roll_end)
proportion = (timer - @ball_roll_end) / (@duration - @ball_roll_end)
# Hide ball sprites
if @ball_sprites[0].visible
@ball_sprites.each { |s| s.visible = false }
@@ -804,13 +807,13 @@ module Transitions
end
def update_anim
if @timer < @ball_spin_end
if timer < @ball_spin_end
# Ball spin
proportion = @timer / @ball_spin_end
proportion = timer / @ball_spin_end
@ball_sprites[0].zoom_x = proportion
@ball_sprites[0].zoom_y = proportion
@ball_sprites[0].angle = 360 * (1 - proportion)
elsif @timer < @slide_start
elsif timer < @slide_start
# Fix zoom/angle of ball sprites
if @ball_sprites[0].src_rect.height == @ball_bitmap.height
@ball_sprites.each_with_index do |sprite, i|
@@ -823,7 +826,7 @@ module Transitions
end
else
# Split overworld/ball apart, move blackness in following them
proportion = (@timer - @slide_start) / (@duration - @slide_start)
proportion = (timer - @slide_start) / (@duration - @slide_start)
@overworld_sprites.each_with_index do |sprite, i|
sprite.x = (0.5 + (((i * 2) - 1) * proportion * proportion)) * Graphics.width
sprite.zoom_x = 1.0 + (proportion * proportion) # Ends at 2x zoom
@@ -906,9 +909,9 @@ module Transitions
end
def update_anim
if @timer < @black_appear_start
if timer < @black_appear_start
# Balls drop down screen while spinning
proportion = @timer / @black_appear_start
proportion = timer / @black_appear_start
@ball_sprites.each_with_index do |sprite, i|
sprite.y = -@ball_bitmap.height - BALL_START_Y_OFFSETS[i]
sprite.y += (Graphics.height + BALL_START_Y_OFFSETS.max + (@ball_bitmap.height * 2)) * proportion
@@ -920,12 +923,12 @@ module Transitions
end
# Black squares appear
@timings.each_with_index do |timing, i|
next if timing < 0 || @timer < timing
next if timing < 0 || timer < timing
@sprites[i].visible = true
@timings[i] = -1
end
# Zoom in overworld sprite
proportion = (@timer - @black_appear_start) / (@duration - @black_appear_start)
proportion = (timer - @black_appear_start) / (@duration - @black_appear_start)
@overworld_sprite.zoom_x = 1.0 + (proportion * proportion) # Ends at 2x zoom
@overworld_sprite.zoom_y = @overworld_sprite.zoom_x
end
@@ -979,9 +982,9 @@ module Transitions
end
def update_anim
if @timer <= @ball_appear_end
if timer <= @ball_appear_end
# Make ball drop down and zoom in
proportion = @timer / @ball_appear_end
proportion = timer / @ball_appear_end
@ball_sprite.y = (-@ball_bitmap.height / 2) + ((Graphics.height + (@ball_bitmap.height * 3)) * proportion * proportion)
@ball_sprite.angle = -1.5 * 360 * proportion
@ball_sprite.zoom_x = 3 * proportion * proportion
@@ -989,7 +992,7 @@ module Transitions
else
@ball_sprite.visible = false
# Black curve and blackness descends
proportion = (@timer - @ball_appear_end) / (@duration - @ball_appear_end)
proportion = (timer - @ball_appear_end) / (@duration - @ball_appear_end)
@sprites.each do |sprite|
sprite.y = -@curve_bitmap.height + ((Graphics.height + @curve_bitmap.height) * proportion)
end
@@ -1065,13 +1068,13 @@ module Transitions
def update_anim
# Make overworld wave strips oscillate
amplitude = MAX_WAVE_AMPLITUDE * [@timer / 0.1, 1].min # Build up to max in 0.1 seconds
amplitude = MAX_WAVE_AMPLITUDE * [timer / 0.1, 1].min # Build up to max in 0.1 seconds
@sprites.each_with_index do |sprite, i|
sprite.x = (1 - ((i % 2) * 2)) * amplitude * Math.sin((@timer * WAVE_SPEED) + (i * WAVE_SPACING))
sprite.x = (1 - ((i % 2) * 2)) * amplitude * Math.sin((timer * WAVE_SPEED) + (i * WAVE_SPACING))
end
# Move balls and trailing blackness up
if @timer >= @ball_rising_start
proportion = (@timer - @ball_rising_start) / (@duration - @ball_rising_start)
if timer >= @ball_rising_start
proportion = (timer - @ball_rising_start) / (@duration - @ball_rising_start)
@ball_sprites.each_with_index do |sprite, i|
sprite.y = (BALL_OFFSETS[i] * Graphics.height) - (Graphics.height * 3.5 * proportion)
sprite.angle = [-1, -1, 1][i] * 360 * 2 * proportion
@@ -1136,22 +1139,22 @@ module Transitions
def update_anim
# Make overworld wave strips oscillate
amplitude = MAX_WAVE_AMPLITUDE * [@timer / 0.1, 1].min # Build up to max in 0.1 seconds
amplitude = MAX_WAVE_AMPLITUDE * [timer / 0.1, 1].min # Build up to max in 0.1 seconds
@sprites.each_with_index do |sprite, i|
sprite.x = (1 - ((i % 2) * 2)) * amplitude * Math.sin((@timer * WAVE_SPEED) + (i * WAVE_SPACING))
sprite.x = (1 - ((i % 2) * 2)) * amplitude * Math.sin((timer * WAVE_SPEED) + (i * WAVE_SPACING))
end
if @timer <= @ball_appear_end
if timer <= @ball_appear_end
# Fade in ball while spinning
proportion = @timer / @ball_appear_end
proportion = timer / @ball_appear_end
@ball_sprite.opacity = 255 * proportion
@ball_sprite.angle = -360 * proportion
elsif @timer <= @black_appear_start
elsif timer <= @black_appear_start
# Fix opacity/angle of ball sprite
@ball_sprite.opacity = 255
@ball_sprite.angle = 0
else
# Spread blackness from centre
proportion = (@timer - @black_appear_start) / (@duration - @black_appear_start)
proportion = (timer - @black_appear_start) / (@duration - @black_appear_start)
@black_sprite.zoom_x = proportion
@black_sprite.zoom_y = proportion * 2
end
@@ -1210,9 +1213,9 @@ module Transitions
end
def update_anim
if @timer <= @ball_appear_end
if timer <= @ball_appear_end
# Balls fly out from centre of screen
proportion = @timer / @ball_appear_end
proportion = timer / @ball_appear_end
ball_travel_x = (Graphics.width + (@ball_bitmap.width * 2)) / 2
ball_travel_y = (Graphics.height + (@ball_bitmap.height * 2)) / 2
@ball_sprites.each_with_index do |sprite, i|
@@ -1221,7 +1224,7 @@ module Transitions
end
else
# Black wedges expand to fill screen
proportion = (@timer - @ball_appear_end) / (@duration - @ball_appear_end)
proportion = (timer - @ball_appear_end) / (@duration - @ball_appear_end)
@sprites.each_with_index do |sprite, i|
sprite.visible = true
sprite.zoom_x = proportion if i.even?
@@ -1349,27 +1352,29 @@ module Transitions
def update_anim
# Bar scrolling
@bar_x -= Graphics.delta_s * BAR_SCROLL_SPEED
@bar_x += @bar_bitmap.width if @bar_x <= -@bar_bitmap.width
@bar_x = -timer * BAR_SCROLL_SPEED
while @bar_x <= -@bar_bitmap.width
@bar_x += @bar_bitmap.width
end
@sprites.each_with_index { |spr, i| spr.x = @bar_x + (i * @bar_bitmap.width) }
# Vibrate VS sprite
vs_phase = (@timer * 30).to_i % 3
vs_phase = (timer * 30).to_i % 3
@vs_main_sprite.x = @vs_x + [0, 4, 0][vs_phase]
@vs_main_sprite.y = @vs_y + [0, 0, -4][vs_phase]
if @timer >= @fade_to_black_start
if timer >= @fade_to_black_start
# Fade to black
@black_sprite.visible = true
proportion = (@timer - @fade_to_black_start) / (@duration - @fade_to_black_start)
proportion = (timer - @fade_to_black_start) / (@duration - @fade_to_black_start)
@flash_viewport.color.alpha = 255 * (1 - proportion)
elsif @timer >= @fade_to_white_start
elsif timer >= @fade_to_white_start
# Slowly fade to white
proportion = (@timer - @fade_to_white_start) / (@fade_to_white_end - @fade_to_white_start)
proportion = (timer - @fade_to_white_start) / (@fade_to_white_end - @fade_to_white_start)
@flash_viewport.color.alpha = 255 * proportion
elsif @timer >= @flash_start + @flash_duration
elsif timer >= @flash_start + @flash_duration
@flash_viewport.color.alpha = 0
elsif @timer >= @flash_start
elsif timer >= @flash_start
# Flash the screen white
proportion = (@timer - @flash_start) / @flash_duration
proportion = (timer - @flash_start) / @flash_duration
if proportion >= 0.5
@flash_viewport.color.alpha = 320 * 2 * (1 - proportion)
@rear_black_sprite.visible = true
@@ -1378,41 +1383,41 @@ module Transitions
else
@flash_viewport.color.alpha = 320 * 2 * proportion
end
elsif @timer >= @foe_appear_end
elsif timer >= @foe_appear_end
@foe_sprite.x = FOE_SPRITE_X
elsif @timer >= @foe_appear_start
elsif timer >= @foe_appear_start
# Foe sprite appears
proportion = (@timer - @foe_appear_start) / (@foe_appear_end - @foe_appear_start)
proportion = (timer - @foe_appear_start) / (@foe_appear_end - @foe_appear_start)
start_x = Graphics.width + (@foe_bitmap.width / 2)
@foe_sprite.x = start_x + ((FOE_SPRITE_X_LIMIT - start_x) * proportion)
elsif @timer >= @vs_appear_final
elsif timer >= @vs_appear_final
@vs_1_sprite.visible = false
elsif @timer >= @vs_appear_start_2
elsif timer >= @vs_appear_start_2
# Temp VS sprites enlarge and shrink again
if @vs_2_sprite.visible
@vs_2_sprite.zoom_x = 1.6 - (0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time)
@vs_2_sprite.zoom_x = 1.6 - (0.8 * (timer - @vs_appear_start_2) / @vs_shrink_time)
@vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x
if @vs_2_sprite.zoom_x <= 1.2
@vs_2_sprite.visible = false
@vs_main_sprite.visible = true
end
end
@vs_1_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time)
@vs_1_sprite.zoom_x = 2.0 - (0.8 * (timer - @vs_appear_start_2) / @vs_shrink_time)
@vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x
elsif @timer >= @vs_appear_start
elsif timer >= @vs_appear_start
# Temp VS sprites appear and start shrinking
@vs_2_sprite.visible = true
@vs_2_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start) / @vs_shrink_time)
@vs_2_sprite.zoom_x = 2.0 - (0.8 * (timer - @vs_appear_start) / @vs_shrink_time)
@vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x
if @vs_1_sprite.visible || @vs_2_sprite.zoom_x <= 1.6 # Halfway between 2.0 and 1.2
@vs_1_sprite.visible = true
@vs_1_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start - (@vs_shrink_time / 2)) / @vs_shrink_time)
@vs_1_sprite.zoom_x = 2.0 - (0.8 * (timer - @vs_appear_start - (@vs_shrink_time / 2)) / @vs_shrink_time)
@vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x
end
elsif @timer >= @bar_appear_end
elsif timer >= @bar_appear_end
@bar_mask_sprite.visible = false
else
start_x = Graphics.width * (1 - (@timer / @bar_appear_end))
start_x = Graphics.width * (1 - (timer / @bar_appear_end))
color = Color.new(0, 0, 0, 0) # Transparent
(@sprites[0].height / 2).times do |i|
x = start_x - (BAR_MASK[i % BAR_MASK.length] * 4)
@@ -1564,15 +1569,15 @@ module Transitions
def update_anim
# Bars/trainer sprites slide in
if @timer > @bar_appear_end
if timer > @bar_appear_end
@player_bar_sprite.x = @player_bar_x
@player_sprite.x = @player_bar_sprite.x + TRAINER_X_OFFSET
@foe_bar_sprite.x = @foe_bar_x
@foe_sprite.x = @foe_bar_sprite.x + (@bar_bitmap.width / 2) - TRAINER_X_OFFSET
@text_sprite.x = @foe_bar_sprite.x
elsif @timer > @bar_appear_start
elsif timer > @bar_appear_start
# Bars/trainer sprites slide in
proportion = (@timer - @bar_appear_start) / (@bar_appear_end - @bar_appear_start)
proportion = (timer - @bar_appear_start) / (@bar_appear_end - @bar_appear_start)
sqrt_proportion = Math.sqrt(proportion)
@player_bar_sprite.x = @player_bar_start_x + ((@player_bar_x + BAR_OVERSHOOT - @player_bar_start_x) * sqrt_proportion)
@player_sprite.x = @player_bar_sprite.x + TRAINER_X_OFFSET
@@ -1581,47 +1586,47 @@ module Transitions
@text_sprite.x = @foe_bar_sprite.x
end
# Animate bars
if @timer >= @flash_start + (0.33 * @flash_duration)
bar_phase = (@timer * 30).to_i % @num_bar_frames
if timer >= @flash_start + (0.33 * @flash_duration)
bar_phase = (timer * 30).to_i % @num_bar_frames
@player_bar_sprite.src_rect.y = bar_phase * BAR_HEIGHT
@foe_bar_sprite.src_rect.y = bar_phase * BAR_HEIGHT
end
# Vibrate VS sprite
vs_phase = (@timer * 30).to_i % 3
vs_phase = (timer * 30).to_i % 3
@vs_main_sprite.x = (Graphics.width / 2) + [0, 4, 0][vs_phase]
@vs_main_sprite.y = (Graphics.height / 2) + [0, 0, -4][vs_phase]
# VS sprites appearing
if @timer >= @vs_appear_final
if timer >= @vs_appear_final
@vs_1_sprite.visible = false
elsif @timer >= @vs_appear_start_2
elsif timer >= @vs_appear_start_2
# Temp VS sprites enlarge and shrink again
if @vs_2_sprite.visible
@vs_2_sprite.zoom_x = 1.6 - (0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time)
@vs_2_sprite.zoom_x = 1.6 - (0.8 * (timer - @vs_appear_start_2) / @vs_shrink_time)
@vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x
if @vs_2_sprite.zoom_x <= 1.2
@vs_2_sprite.visible = false
@vs_main_sprite.visible = true
end
end
@vs_1_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time)
@vs_1_sprite.zoom_x = 2.0 - (0.8 * (timer - @vs_appear_start_2) / @vs_shrink_time)
@vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x
elsif @timer >= @vs_appear_start
elsif timer >= @vs_appear_start
# Temp VS sprites appear and start shrinking
@vs_2_sprite.visible = true
@vs_2_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start) / @vs_shrink_time)
@vs_2_sprite.zoom_x = 2.0 - (0.8 * (timer - @vs_appear_start) / @vs_shrink_time)
@vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x
if @vs_1_sprite.visible || @vs_2_sprite.zoom_x <= 1.6 # Halfway between 2.0 and 1.2
@vs_1_sprite.visible = true
@vs_1_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start - (@vs_shrink_time / 2)) / @vs_shrink_time)
@vs_1_sprite.zoom_x = 2.0 - (0.8 * (timer - @vs_appear_start - (@vs_shrink_time / 2)) / @vs_shrink_time)
@vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x
end
end
# Flash white (two flashes)
if @timer >= @flash_start + @flash_duration
if timer >= @flash_start + @flash_duration
@flash_viewport.color.alpha = 0
elsif @timer >= @flash_start
elsif timer >= @flash_start
# Flash the screen white (coming from white lasts twice as long as going to white)
proportion = (@timer - @flash_start) / @flash_duration
proportion = (timer - @flash_start) / @flash_duration
if proportion >= 0.33 # Coming from white
@flash_viewport.color.alpha = 320 * 3 * (1 - proportion) / 2
@player_sprite.color.alpha = 0
@@ -1629,11 +1634,11 @@ module Transitions
else # Going to white
@flash_viewport.color.alpha = 320 * 3 * proportion
end
elsif @timer >= @flash_1_start + @flash_1_duration
elsif timer >= @flash_1_start + @flash_1_duration
@flash_viewport.color.alpha = 0
elsif @timer >= @flash_1_start
elsif timer >= @flash_1_start
# Flash the screen white
proportion = (@timer - @flash_1_start) / @flash_1_duration
proportion = (timer - @flash_1_start) / @flash_1_duration
if proportion >= 0.5 # Coming from white
@flash_viewport.color.alpha = 320 * 2 * (1 - proportion)
@rear_black_sprite.visible = true
@@ -1642,15 +1647,15 @@ module Transitions
end
end
# Fade to white at end
if @timer >= @fade_to_black_start
if timer >= @fade_to_black_start
# Fade to black
@black_sprite.visible = true
proportion = (@timer - @fade_to_black_start) / (@duration - @fade_to_black_start)
proportion = (timer - @fade_to_black_start) / (@duration - @fade_to_black_start)
@flash_viewport.color.alpha = 255 * (1 - proportion)
elsif @timer >= @fade_to_white_start
elsif timer >= @fade_to_white_start
@text_sprite.visible = false
# Slowly fade to white
proportion = (@timer - @fade_to_white_start) / (@fade_to_white_end - @fade_to_white_start)
proportion = (timer - @fade_to_white_start) / (@fade_to_white_end - @fade_to_white_start)
@flash_viewport.color.alpha = 255 * proportion
# Move bars and trainer sprites off-screen
dist = BAR_Y_INDENT + BAR_HEIGHT
@@ -1724,9 +1729,9 @@ module Transitions
end
def update_anim
if @timer <= @rocket_appear_end
if timer <= @rocket_appear_end
# Rocket logos fly in from edges of screen
proportion = @timer / @rocket_appear_end
proportion = timer / @rocket_appear_end
@rocket_sprites.each_with_index do |sprite, i|
next if !sprite.visible
start_time = i * @rocket_appear_delay
@@ -1743,7 +1748,7 @@ module Transitions
else
@rocket_sprites.last.visible = false
# Black wedges expand to fill screen
proportion = (@timer - @rocket_appear_end) / (@duration - @rocket_appear_end)
proportion = (timer - @rocket_appear_end) / (@duration - @rocket_appear_end)
@sprites.each_with_index do |sprite, i|
sprite.visible = true
sprite.zoom_x = proportion if i.even?
@@ -1848,64 +1853,66 @@ module Transitions
def update_anim
# Strobes scrolling
if @sprites[0].visible
@strobes_x -= Graphics.delta_s * STROBE_SCROLL_SPEED
@strobes_x += @strobes_bitmap.width if @strobes_x <= -@strobes_bitmap.width
@strobes_x = -timer * STROBE_SCROLL_SPEED
while @strobes_x <= -@strobes_bitmap.width
@strobes_x += @strobes_bitmap.width
end
@sprites.each_with_index { |spr, i| spr.x = @strobes_x + (i * @strobes_bitmap.width) }
end
if @timer >= @fade_to_black_start
if timer >= @fade_to_black_start
# Fade to black
proportion = (@timer - @fade_to_black_start) / (@duration - @fade_to_black_start)
proportion = (timer - @fade_to_black_start) / (@duration - @fade_to_black_start)
@flash_viewport.color.alpha = 255 * (1 - proportion)
elsif @timer >= @fade_to_white_end
elsif timer >= @fade_to_white_end
@flash_viewport.color.alpha = 255 # Ensure screen is white
@black_sprite.visible = true # Make black overlay visible
elsif @timer >= @foe_disappear_end
elsif timer >= @foe_disappear_end
@foe_sprite.visible = false # Ensure foe sprite has vanished
@text_sprite.visible = false # Ensure name sprite has vanished
# Slowly fade to white
proportion = (@timer - @foe_disappear_end) / (@fade_to_white_end - @foe_disappear_end)
proportion = (timer - @foe_disappear_end) / (@fade_to_white_end - @foe_disappear_end)
@flash_viewport.color.alpha = 255 * proportion
elsif @timer >= @foe_disappear_start
elsif timer >= @foe_disappear_start
# Slide foe sprite/name off-screen
proportion = (@timer - @foe_disappear_start) / (@foe_disappear_end - @foe_disappear_start)
proportion = (timer - @foe_disappear_start) / (@foe_disappear_end - @foe_disappear_start)
start_x = Graphics.width / 2
@foe_sprite.x = start_x - ((@foe_bitmap.width + start_x) * proportion * proportion)
@text_sprite.x = @foe_sprite.x - (Graphics.width / 2)
elsif @timer >= @flash_end
elsif timer >= @flash_end
@flash_viewport.color.alpha = 0 # Ensure flash has ended
elsif @timer >= @bg_2_appear_end
elsif timer >= @bg_2_appear_end
@bg_2_sprite.opacity = 255 # Ensure BG 2 sprite is fully opaque
@foe_sprite.x = Graphics.width / 2 # Ensure foe sprite is in the right place
@text_sprite.x = 0 # Ensure name sprite is in the right place
# Flash screen
proportion = (@timer - @bg_2_appear_end) / (@flash_end - @bg_2_appear_end)
proportion = (timer - @bg_2_appear_end) / (@flash_end - @bg_2_appear_end)
@flash_viewport.color.alpha = 320 * (1 - proportion)
elsif @timer >= @bg_2_appear_start
elsif timer >= @bg_2_appear_start
# BG 2 sprite appears
proportion = (@timer - @bg_2_appear_start) / (@bg_2_appear_end - @bg_2_appear_start)
proportion = (timer - @bg_2_appear_start) / (@bg_2_appear_end - @bg_2_appear_start)
@bg_2_sprite.opacity = 255 * proportion
# Foe sprite/name appear
start_x = Graphics.width + (@foe_bitmap.width / 2)
@foe_sprite.x = start_x + (((Graphics.width / 2) - start_x) * Math.sqrt(proportion))
@text_sprite.x = @foe_sprite.x - (Graphics.width / 2)
@text_sprite.visible = true
elsif @timer >= @bg_1_appear_end
elsif timer >= @bg_1_appear_end
@bg_1_sprite.oy = Graphics.height / 2
@bg_1_sprite.src_rect.y = 0
@bg_1_sprite.src_rect.height = @bg_1_bitmap.height
@sprites.each { |sprite| sprite.visible = false } # Hide strobes
elsif @timer >= @bg_1_appear_start
elsif timer >= @bg_1_appear_start
@flash_viewport.color.alpha = 0 # Ensure flash has ended
# BG 1 sprite appears
proportion = (@timer - @bg_1_appear_start) / (@bg_1_appear_end - @bg_1_appear_start)
proportion = (timer - @bg_1_appear_start) / (@bg_1_appear_end - @bg_1_appear_start)
half_height = ((proportion * @bg_1_bitmap.height) / 2).to_i
@bg_1_sprite.src_rect.height = half_height * 2
@bg_1_sprite.src_rect.y = (@bg_1_bitmap.height / 2) - half_height
@bg_1_sprite.oy = half_height
elsif @timer >= @strobe_appear_end
elsif timer >= @strobe_appear_end
@sprites.each { |sprite| sprite.opacity = 255 } # Ensure strobes are fully opaque
# Flash the screen white
proportion = (@timer - @strobe_appear_end) / (@bg_1_appear_start - @strobe_appear_end)
proportion = (timer - @strobe_appear_end) / (@bg_1_appear_start - @strobe_appear_end)
if proportion >= 0.5
@flash_viewport.color.alpha = 320 * 2 * (1 - proportion)
else
@@ -1914,7 +1921,7 @@ module Transitions
else
# Strobes fade in
@sprites.each do |sprite|
sprite.opacity = 255 * (@timer / @strobe_appear_end)
sprite.opacity = 255 * (timer / @strobe_appear_end)
end
end
end

View File

@@ -172,10 +172,9 @@ class Battle::Scene
return if !@briefMessage
pbShowWindow(MESSAGE_BOX)
cw = @sprites["messageWindow"]
timer = 0.0
while timer < MESSAGE_PAUSE_TIME
timer_start = System.uptime
while System.uptime - timer_start < MESSAGE_PAUSE_TIME
pbUpdate(cw)
timer += Graphics.delta_s
end
cw.text = ""
cw.visible = false
@@ -191,7 +190,7 @@ class Battle::Scene
cw.setText(msg)
PBDebug.log_message(msg)
yielded = false
timer = 0.0
timer_start = System.uptime
loop do
pbUpdate(cw)
if !cw.busy?
@@ -205,12 +204,11 @@ class Battle::Scene
@briefMessage = true
break
end
if timer >= MESSAGE_PAUSE_TIME # Autoclose after 1 second
if System.uptime - timer_start >= MESSAGE_PAUSE_TIME # Autoclose after 1 second
cw.text = ""
cw.visible = false
break
end
timer += Graphics.delta_s
end
if Input.trigger?(Input::BACK) || Input.trigger?(Input::USE) || @abortable
if cw.busy?
@@ -237,7 +235,7 @@ class Battle::Scene
cw.text = msg + "\1"
PBDebug.log_message(msg)
yielded = false
timer = 0.0
timer_start = System.uptime
loop do
pbUpdate(cw)
if !cw.busy?
@@ -246,12 +244,11 @@ class Battle::Scene
yielded = true
end
if !@battleEnd
if timer >= MESSAGE_PAUSE_TIME * 3 # Autoclose after 3 seconds
if System.uptime - timer_start >= MESSAGE_PAUSE_TIME * 3 # Autoclose after 3 seconds
cw.text = ""
cw.visible = false
break
end
timer += Graphics.delta_s
end
end
if Input.trigger?(Input::BACK) || Input.trigger?(Input::USE) || @abortable

View File

@@ -345,11 +345,10 @@ class Battle::Scene
return if @battle.opponent
@briefMessage = false
pbMEPlay(pbGetWildCaptureME)
timer = 0.0
timer_start = System.uptime
loop do
pbUpdate
timer += Graphics.delta_s
break if timer >= 3.5
break if System.uptime - timer_start >= 3.5
end
pbMEStop
end

View File

@@ -271,7 +271,7 @@ module RPG
def update_sprite_position(sprite, index, is_new_sprite = false)
return if !sprite || !sprite.bitmap || !sprite.visible
delta_t = Graphics.delta_s
delta_t = Graphics.delta
lifetimes = (is_new_sprite) ? @new_sprite_lifetimes : @sprite_lifetimes
if lifetimes[index] >= 0
lifetimes[index] -= delta_t
@@ -310,7 +310,7 @@ module RPG
end
def recalculate_tile_positions
delta_t = Graphics.delta_s
delta_t = Graphics.delta
weather_type = @type
if @fading && @fade_time >= [FADE_OLD_TONE_END - @time_shift, 0].max
weather_type = @target_type
@@ -411,7 +411,7 @@ module RPG
@sun_magnitude = weather_max if @sun_magnitude != weather_max && @sun_magnitude != -weather_max
@sun_magnitude *= -1 if (@sun_magnitude > 0 && @sun_strength > @sun_magnitude) ||
(@sun_magnitude < 0 && @sun_strength < 0)
@sun_strength += @sun_magnitude.to_f * Graphics.delta_s / 0.4 # 0.4 seconds per half flash
@sun_strength += @sun_magnitude.to_f * Graphics.delta / 0.4 # 0.4 seconds per half flash
tone_red += @sun_strength
tone_green += @sun_strength
tone_blue += @sun_strength / 2
@@ -424,7 +424,7 @@ module RPG
def update_fading
return if !@fading
old_fade_time = @fade_time
@fade_time += Graphics.delta_s
@fade_time += Graphics.delta
# Change tile bitmaps
if @type != @target_type
tile_change_threshold = [FADE_OLD_TONE_END - @time_shift, 0].max
@@ -483,7 +483,7 @@ module RPG
# Storm flashes
if @type == :Storm && !@fading
if @time_until_flash > 0
@time_until_flash -= Graphics.delta_s
@time_until_flash -= Graphics.delta
if @time_until_flash <= 0
@viewport.flash(Color.new(255, 255, 255, 230), rand(2..4) * 20)
end

View File

@@ -139,13 +139,12 @@ def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil)
$PokemonEncounters.reset_step_count
# Fade back to the overworld in 0.4 seconds
viewport.color = Color.black
timer = 0.0
timer_start = System.uptime
loop do
Graphics.update
Input.update
pbUpdateSceneMap
timer += Graphics.delta_s
viewport.color.alpha = 255 * (1 - (timer / 0.4))
viewport.color.alpha = 255 * (1 - ((System.uptime - timer_start) / 0.4))
break if viewport.color.alpha <= 0
end
viewport.dispose
@@ -159,17 +158,16 @@ def pbBattleAnimationCore(anim, viewport, location, num_flashes = 2)
viewport.color = Color.new(c, c, c) # Fade to black/white a few times
half_flash_time = 0.2 # seconds
num_flashes.times do # 2 flashes
timer = 0.0
timer_start = System.uptime
loop do
if timer < half_flash_time
viewport.color.alpha = 255 * timer / half_flash_time
if System.uptime - timer_start < half_flash_time
viewport.color.alpha = 255 * (System.uptime - timer_start) / half_flash_time
else
viewport.color.alpha = 255 * (2 - (timer / half_flash_time))
viewport.color.alpha = 255 * (2 - ((System.uptime - timer_start) / half_flash_time))
end
timer += Graphics.delta_s
Graphics.update
pbUpdateSceneMap
break if timer >= half_flash_time * 2
break if System.uptime - timer_start >= half_flash_time * 2
end
end
viewport.color.alpha = 0

View File

@@ -574,7 +574,7 @@ EventHandlers.add(:on_frame_update, :phone_call_counter,
if $PokemonGlobal.phone.time_to_next_call <= 0
$PokemonGlobal.phone.time_to_next_call = rand(20...40) * 60.0 # 20-40 minutes
end
$PokemonGlobal.phone.time_to_next_call -= Graphics.delta_s
$PokemonGlobal.phone.time_to_next_call -= Graphics.delta
next if $PokemonGlobal.phone.time_to_next_call > 0
# Time for a random phone call; generate one
Phone::Call.make_incoming

View File

@@ -33,7 +33,7 @@ class IntroEventScene < EventScene
# fade to opacity 255 in FADE_TICKS ticks after waiting 0 frames
@pic.moveOpacity(0, FADE_TICKS, 255)
pictureWait
@timer = 0.0 # reset the timer
@timer = System.uptime # reset the timer
onUpdate.set(method(:splash_update)) # called every frame
onCTrigger.set(method(:close_splash)) # called when C key is pressed
end
@@ -52,8 +52,7 @@ class IntroEventScene < EventScene
end
def splash_update(scene, args)
@timer += Graphics.delta_s
close_splash(scene, args) if @timer > SECONDS_PER_SPLASH
close_splash(scene, args) if System.uptime - @timer >= SECONDS_PER_SPLASH
end
def open_title_screen(_scene, *args)

View File

@@ -539,13 +539,12 @@ class PokemonEvolutionScene
pbPlayDecisionSE
@pokemon.play_cry
@sprites["msgwindow"].text = _INTL("{1} is evolving!", @pokemon.name)
timer = 0.0
timer_start = System.uptime
loop do
Graphics.update
Input.update
pbUpdate
timer += Graphics.delta_s
break if timer >= 1.0
break if System.uptime - timer_start >= 1
end
oldstate = pbSaveSpriteState(@sprites["rsprite1"])
oldstate2 = pbSaveSpriteState(@sprites["rsprite2"])

View File

@@ -101,10 +101,11 @@ class Scene_Credits
# Stop Editing
def main
@quit = false
#-------------------------------
# Animated Background Setup
#-------------------------------
@counter = 0.0 # Counts time elapsed since the background image changed
@timer_start = System.uptime # Time when the credits started
@bg_index = 0
@bitmap_height = Graphics.height # For a single credits text bitmap
@trim = Graphics.height / 10
@@ -198,55 +199,46 @@ class Scene_Credits
Graphics.update
Input.update
update
break if $scene != self
break if @quit
end
pbBGMFade(2.0)
$game_temp.background_bitmap = Graphics.snap_to_bitmap
pbBGMFade(2.0)
Graphics.freeze
viewport.color = Color.black # Ensure screen is black
text_viewport.color = Color.black # Ensure screen is black
Graphics.transition(8, "fadetoblack")
$game_temp.background_bitmap.dispose
@background_sprite.dispose
@credit_sprites.each { |s| s&.dispose }
text_viewport.dispose
viewport.dispose
text_viewport.dispose
$PokemonGlobal.creditsPlayed = true
pbBGMPlay(previousBGM)
$scene = ($game_map) ? Scene_Map.new : nil
end
# Check if the credits should be cancelled
def cancel?
if Input.trigger?(Input::USE) && $PokemonGlobal.creditsPlayed
$scene = Scene_Map.new
pbBGMFade(1.0)
return true
end
return false
@quit = true if Input.trigger?(Input::USE) && $PokemonGlobal.creditsPlayed
return @quit
end
# Checks if credits bitmap has reached its ending point
def last?
if @realOY > @total_height + @trim
$scene = ($game_map) ? Scene_Map.new : nil
pbBGMFade(2.0)
return true
end
return false
@quit = true if @realOY > @total_height + @trim
return @quit
end
def update
delta = Graphics.delta_s
@counter += delta
# Go to next slide
if @counter >= SECONDS_PER_BACKGROUND
@counter -= SECONDS_PER_BACKGROUND
@bg_index += 1
@bg_index = 0 if @bg_index >= BACKGROUNDS_LIST.length
new_bg_index = ((System.uptime - @timer_start) / SECONDS_PER_BACKGROUND) % BACKGROUNDS_LIST.length
if @bg_index != new_bg_index
@bg_index = new_bg_index
@background_sprite.setBitmap("Graphics/Titles/" + BACKGROUNDS_LIST[@bg_index])
end
return if cancel?
return if last?
@realOY += SCROLL_SPEED * delta
@realOY = SCROLL_SPEED * (System.uptime - @timer_start) - Graphics.height + @trim
@credit_sprites.each_with_index { |s, i| s.oy = @realOY - (@bitmap_height * i) }
end
end

View File

@@ -221,13 +221,12 @@ class TriadScene
def pbDisplay(text)
@sprites["helpwindow"].text = text
timer = 0.0
timer_start = System.uptime
loop do
Graphics.update
Input.update
pbUpdate
timer += Graphics.delta_s
break if timer >= 1.5
break if System.uptime - timer_start >= 1.5
end
end