mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Removed last possible usages of Graphics.frame_rate and Graphics.frame_count, improved screen scrolling code, player now animates walking into a wall
This commit is contained in:
@@ -35,11 +35,13 @@ class SpriteAnimation
|
|||||||
@_animation_hit = hit
|
@_animation_hit = hit
|
||||||
@_animation_height = height
|
@_animation_height = height
|
||||||
@_animation_duration = @_animation.frame_max
|
@_animation_duration = @_animation.frame_max
|
||||||
|
@_animation_index = 0
|
||||||
fr = 20
|
fr = 20
|
||||||
if @_animation.name[/\[\s*(\d+?)\s*\]\s*$/]
|
if @_animation.name[/\[\s*(\d+?)\s*\]\s*$/]
|
||||||
fr = $~[1].to_i
|
fr = $~[1].to_i
|
||||||
end
|
end
|
||||||
@_animation_frame_skip = Graphics.frame_rate / fr
|
@_animation_time_per_frame = 1.0 / fr
|
||||||
|
@_animation_timer_start = System.uptime
|
||||||
animation_name = @_animation.animation_name
|
animation_name = @_animation.animation_name
|
||||||
animation_hue = @_animation.animation_hue
|
animation_hue = @_animation.animation_hue
|
||||||
bitmap = pbGetAnimation(animation_name, animation_hue)
|
bitmap = pbGetAnimation(animation_name, animation_hue)
|
||||||
@@ -66,12 +68,14 @@ class SpriteAnimation
|
|||||||
dispose_loop_animation
|
dispose_loop_animation
|
||||||
@_loop_animation = animation
|
@_loop_animation = animation
|
||||||
return if @_loop_animation.nil?
|
return if @_loop_animation.nil?
|
||||||
|
@_loop_animation_duration = @_animation.frame_max
|
||||||
@_loop_animation_index = 0
|
@_loop_animation_index = 0
|
||||||
fr = 20
|
fr = 20
|
||||||
if @_animation.name[/\[\s*(\d+?)\s*\]\s*$/]
|
if @_animation.name[/\[\s*(\d+?)\s*\]\s*$/]
|
||||||
fr = $~[1].to_i
|
fr = $~[1].to_i
|
||||||
end
|
end
|
||||||
@_loop_animation_frame_skip = Graphics.frame_rate / fr
|
@_loop_animation_time_per_frame = 1.0 / fr
|
||||||
|
@_loop_animation_timer_start = System.uptime
|
||||||
animation_name = @_loop_animation.animation_name
|
animation_name = @_loop_animation.animation_name
|
||||||
animation_hue = @_loop_animation.animation_hue
|
animation_hue = @_loop_animation.animation_hue
|
||||||
bitmap = pbGetAnimation(animation_name, animation_hue)
|
bitmap = pbGetAnimation(animation_name, animation_hue)
|
||||||
@@ -100,6 +104,7 @@ class SpriteAnimation
|
|||||||
@_animation_sprites.each { |s| s.dispose }
|
@_animation_sprites.each { |s| s.dispose }
|
||||||
@_animation_sprites = nil
|
@_animation_sprites = nil
|
||||||
@_animation = nil
|
@_animation = nil
|
||||||
|
@_animation_duration = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def dispose_loop_animation
|
def dispose_loop_animation
|
||||||
@@ -123,30 +128,19 @@ class SpriteAnimation
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if @_animation
|
update_animation if @_animation
|
||||||
quick_update = true
|
update_loop_animation if @_loop_animation
|
||||||
if Graphics.frame_count % @_animation_frame_skip == 0
|
|
||||||
@_animation_duration -= 1
|
|
||||||
quick_update = false
|
|
||||||
end
|
|
||||||
update_animation(quick_update)
|
|
||||||
end
|
|
||||||
if @_loop_animation
|
|
||||||
quick_update = (Graphics.frame_count % @_loop_animation_frame_skip != 0)
|
|
||||||
update_loop_animation(quick_update)
|
|
||||||
if !quick_update
|
|
||||||
@_loop_animation_index += 1
|
|
||||||
@_loop_animation_index %= @_loop_animation.frame_max
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_animation(quick_update = false)
|
def update_animation
|
||||||
if @_animation_duration <= 0
|
new_index = ((System.uptime - @_animation_timer_start) / @_animation_time_per_frame).to_i
|
||||||
|
if new_index >= @_animation_duration
|
||||||
dispose_animation
|
dispose_animation
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
frame_index = @_animation.frame_max - @_animation_duration
|
quick_update = (@_animation_index == new_index)
|
||||||
|
@_animation_index = new_index
|
||||||
|
frame_index = @_animation_index
|
||||||
cell_data = @_animation.frames[frame_index].cell_data
|
cell_data = @_animation.frames[frame_index].cell_data
|
||||||
position = @_animation.position
|
position = @_animation.position
|
||||||
animation_set_sprites(@_animation_sprites, cell_data, position, quick_update)
|
animation_set_sprites(@_animation_sprites, cell_data, position, quick_update)
|
||||||
@@ -158,6 +152,10 @@ class SpriteAnimation
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_loop_animation(quick_update = false)
|
def update_loop_animation(quick_update = false)
|
||||||
|
new_index = ((System.uptime - @_loop_animation_timer_start) / @_loop_animation_time_per_frame).to_i
|
||||||
|
new_index %= @_loop_animation_duration
|
||||||
|
quick_update = (@_loop_animation_index == new_index)
|
||||||
|
@_loop_animation_index = new_index
|
||||||
frame_index = @_loop_animation_index
|
frame_index = @_loop_animation_index
|
||||||
cell_data = @_loop_animation.frames[frame_index].cell_data
|
cell_data = @_loop_animation.frames[frame_index].cell_data
|
||||||
position = @_loop_animation.position
|
position = @_loop_animation.position
|
||||||
@@ -268,6 +266,7 @@ module RPG
|
|||||||
@_collapse_duration = 0
|
@_collapse_duration = 0
|
||||||
@_damage_duration = 0
|
@_damage_duration = 0
|
||||||
@_animation_duration = 0
|
@_animation_duration = 0
|
||||||
|
@_animation_frame = 0
|
||||||
@_blink = false
|
@_blink = false
|
||||||
@animations = []
|
@animations = []
|
||||||
@loopAnimations = []
|
@loopAnimations = []
|
||||||
@@ -387,16 +386,12 @@ module RPG
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispose_animation
|
def dispose_animation
|
||||||
@animations.each do |a|
|
@animations.each { |a| a&.dispose_animation }
|
||||||
a&.dispose_animation
|
|
||||||
end
|
|
||||||
@animations.clear
|
@animations.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
def dispose_loop_animation
|
def dispose_loop_animation
|
||||||
@loopAnimations.each do |a|
|
@loopAnimations.each { |a| a&.dispose_loop_animation }
|
||||||
a&.dispose_loop_animation
|
|
||||||
end
|
|
||||||
@loopAnimations.clear
|
@loopAnimations.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -422,9 +417,7 @@ module RPG
|
|||||||
return true if @_escape_duration > 0
|
return true if @_escape_duration > 0
|
||||||
return true if @_collapse_duration > 0
|
return true if @_collapse_duration > 0
|
||||||
return true if @_damage_duration > 0
|
return true if @_damage_duration > 0
|
||||||
@animations.each do |a|
|
@animations.each { |a| return true if a.effect? }
|
||||||
return true if a.effect?
|
|
||||||
end
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -461,12 +454,8 @@ module RPG
|
|||||||
@_damage_sprite.opacity = 256 - ((12 - @_damage_duration) * 32)
|
@_damage_sprite.opacity = 256 - ((12 - @_damage_duration) * 32)
|
||||||
dispose_damage if @_damage_duration == 0
|
dispose_damage if @_damage_duration == 0
|
||||||
end
|
end
|
||||||
@animations.each do |a|
|
@animations.each { |a| a.update }
|
||||||
a.update
|
@loopAnimations.each { |a| a.update }
|
||||||
end
|
|
||||||
@loopAnimations.each do |a|
|
|
||||||
a.update
|
|
||||||
end
|
|
||||||
if @_blink
|
if @_blink
|
||||||
@_blink_count = (@_blink_count + 1) % 32
|
@_blink_count = (@_blink_count + 1) % 32
|
||||||
if @_blink_count < 16
|
if @_blink_count < 16
|
||||||
@@ -480,34 +469,22 @@ module RPG
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_animation
|
def update_animation
|
||||||
@animations.each do |a|
|
@animations.each { |a| a.update_animation if a&.active? }
|
||||||
a.update_animation if a&.active?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_loop_animation
|
def update_loop_animation
|
||||||
@loopAnimations.each do |a|
|
@loopAnimations.each { |a| a.update_loop_animation if a&.active? }
|
||||||
a.update_loop_animation if a&.active?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def x=(x)
|
def x=(x)
|
||||||
@animations.each do |a|
|
@animations.each { |a| a.x = x if a }
|
||||||
a.x = x if a
|
@loopAnimations.each { |a| a.x = x if a }
|
||||||
end
|
|
||||||
@loopAnimations.each do |a|
|
|
||||||
a.x = x if a
|
|
||||||
end
|
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def y=(y)
|
def y=(y)
|
||||||
@animations.each do |a|
|
@animations.each { |a| a.y = y if a }
|
||||||
a.y = y if a
|
@loopAnimations.each { |a| a.y = y if a }
|
||||||
end
|
|
||||||
@loopAnimations.each do |a|
|
|
||||||
a.y = y if a
|
|
||||||
end
|
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ def lerp(start_val, end_val, duration, delta, now = nil)
|
|||||||
delta = now - delta if now
|
delta = now - delta if now
|
||||||
return start_val if delta <= 0
|
return start_val if delta <= 0
|
||||||
return end_val if delta >= duration
|
return end_val if delta >= duration
|
||||||
return start_val + (end_val - start_val) * delta / duration
|
return start_val + (end_val - start_val) * delta / duration.to_f
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ SaveData.register(:player) do
|
|||||||
save_value { $player }
|
save_value { $player }
|
||||||
load_value { |value| $player = value }
|
load_value { |value| $player = value }
|
||||||
new_game_value { Player.new("Unnamed", GameData::TrainerType.keys.first) }
|
new_game_value { Player.new("Unnamed", GameData::TrainerType.keys.first) }
|
||||||
from_old_format { |old_format| old_format[0] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated This save data is slated to be removed in v22, as its use is
|
||||||
|
# replaced by $stats.play_time.
|
||||||
SaveData.register(:frame_count) do
|
SaveData.register(:frame_count) do
|
||||||
ensure_class :Integer
|
ensure_class :Integer
|
||||||
save_value { Graphics.frame_count }
|
save_value { Graphics.frame_count }
|
||||||
load_value { |value| Graphics.frame_count = value }
|
load_value { |value| Graphics.frame_count = value }
|
||||||
new_game_value { 0 }
|
new_game_value { 0 }
|
||||||
from_old_format { |old_format| old_format[1] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SaveData.register(:game_system) do
|
SaveData.register(:game_system) do
|
||||||
@@ -22,7 +22,6 @@ SaveData.register(:game_system) do
|
|||||||
save_value { $game_system }
|
save_value { $game_system }
|
||||||
load_value { |value| $game_system = value }
|
load_value { |value| $game_system = value }
|
||||||
new_game_value { Game_System.new }
|
new_game_value { Game_System.new }
|
||||||
from_old_format { |old_format| old_format[2] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SaveData.register(:pokemon_system) do
|
SaveData.register(:pokemon_system) do
|
||||||
@@ -31,7 +30,6 @@ SaveData.register(:pokemon_system) do
|
|||||||
save_value { $PokemonSystem }
|
save_value { $PokemonSystem }
|
||||||
load_value { |value| $PokemonSystem = value }
|
load_value { |value| $PokemonSystem = value }
|
||||||
new_game_value { PokemonSystem.new }
|
new_game_value { PokemonSystem.new }
|
||||||
from_old_format { |old_format| old_format[3] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SaveData.register(:switches) do
|
SaveData.register(:switches) do
|
||||||
@@ -39,7 +37,6 @@ SaveData.register(:switches) do
|
|||||||
save_value { $game_switches }
|
save_value { $game_switches }
|
||||||
load_value { |value| $game_switches = value }
|
load_value { |value| $game_switches = value }
|
||||||
new_game_value { Game_Switches.new }
|
new_game_value { Game_Switches.new }
|
||||||
from_old_format { |old_format| old_format[5] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SaveData.register(:variables) do
|
SaveData.register(:variables) do
|
||||||
@@ -47,7 +44,6 @@ SaveData.register(:variables) do
|
|||||||
save_value { $game_variables }
|
save_value { $game_variables }
|
||||||
load_value { |value| $game_variables = value }
|
load_value { |value| $game_variables = value }
|
||||||
new_game_value { Game_Variables.new }
|
new_game_value { Game_Variables.new }
|
||||||
from_old_format { |old_format| old_format[6] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SaveData.register(:self_switches) do
|
SaveData.register(:self_switches) do
|
||||||
@@ -55,7 +51,6 @@ SaveData.register(:self_switches) do
|
|||||||
save_value { $game_self_switches }
|
save_value { $game_self_switches }
|
||||||
load_value { |value| $game_self_switches = value }
|
load_value { |value| $game_self_switches = value }
|
||||||
new_game_value { Game_SelfSwitches.new }
|
new_game_value { Game_SelfSwitches.new }
|
||||||
from_old_format { |old_format| old_format[7] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SaveData.register(:game_screen) do
|
SaveData.register(:game_screen) do
|
||||||
@@ -63,14 +58,12 @@ SaveData.register(:game_screen) do
|
|||||||
save_value { $game_screen }
|
save_value { $game_screen }
|
||||||
load_value { |value| $game_screen = value }
|
load_value { |value| $game_screen = value }
|
||||||
new_game_value { Game_Screen.new }
|
new_game_value { Game_Screen.new }
|
||||||
from_old_format { |old_format| old_format[8] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SaveData.register(:map_factory) do
|
SaveData.register(:map_factory) do
|
||||||
ensure_class :PokemonMapFactory
|
ensure_class :PokemonMapFactory
|
||||||
save_value { $map_factory }
|
save_value { $map_factory }
|
||||||
load_value { |value| $map_factory = value }
|
load_value { |value| $map_factory = value }
|
||||||
from_old_format { |old_format| old_format[9] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SaveData.register(:game_player) do
|
SaveData.register(:game_player) do
|
||||||
@@ -78,7 +71,6 @@ SaveData.register(:game_player) do
|
|||||||
save_value { $game_player }
|
save_value { $game_player }
|
||||||
load_value { |value| $game_player = value }
|
load_value { |value| $game_player = value }
|
||||||
new_game_value { Game_Player.new }
|
new_game_value { Game_Player.new }
|
||||||
from_old_format { |old_format| old_format[10] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SaveData.register(:global_metadata) do
|
SaveData.register(:global_metadata) do
|
||||||
@@ -86,7 +78,6 @@ SaveData.register(:global_metadata) do
|
|||||||
save_value { $PokemonGlobal }
|
save_value { $PokemonGlobal }
|
||||||
load_value { |value| $PokemonGlobal = value }
|
load_value { |value| $PokemonGlobal = value }
|
||||||
new_game_value { PokemonGlobalMetadata.new }
|
new_game_value { PokemonGlobalMetadata.new }
|
||||||
from_old_format { |old_format| old_format[11] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SaveData.register(:map_metadata) do
|
SaveData.register(:map_metadata) do
|
||||||
@@ -94,7 +85,6 @@ SaveData.register(:map_metadata) do
|
|||||||
save_value { $PokemonMap }
|
save_value { $PokemonMap }
|
||||||
load_value { |value| $PokemonMap = value }
|
load_value { |value| $PokemonMap = value }
|
||||||
new_game_value { PokemonMapMetadata.new }
|
new_game_value { PokemonMapMetadata.new }
|
||||||
from_old_format { |old_format| old_format[12] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SaveData.register(:bag) do
|
SaveData.register(:bag) do
|
||||||
@@ -102,7 +92,6 @@ SaveData.register(:bag) do
|
|||||||
save_value { $bag }
|
save_value { $bag }
|
||||||
load_value { |value| $bag = value }
|
load_value { |value| $bag = value }
|
||||||
new_game_value { PokemonBag.new }
|
new_game_value { PokemonBag.new }
|
||||||
from_old_format { |old_format| old_format[13] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SaveData.register(:storage_system) do
|
SaveData.register(:storage_system) do
|
||||||
@@ -110,7 +99,6 @@ SaveData.register(:storage_system) do
|
|||||||
save_value { $PokemonStorage }
|
save_value { $PokemonStorage }
|
||||||
load_value { |value| $PokemonStorage = value }
|
load_value { |value| $PokemonStorage = value }
|
||||||
new_game_value { PokemonStorage.new }
|
new_game_value { PokemonStorage.new }
|
||||||
from_old_format { |old_format| old_format[14] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SaveData.register(:essentials_version) do
|
SaveData.register(:essentials_version) do
|
||||||
@@ -119,7 +107,6 @@ SaveData.register(:essentials_version) do
|
|||||||
save_value { Essentials::VERSION }
|
save_value { Essentials::VERSION }
|
||||||
load_value { |value| $save_engine_version = value }
|
load_value { |value| $save_engine_version = value }
|
||||||
new_game_value { Essentials::VERSION }
|
new_game_value { Essentials::VERSION }
|
||||||
from_old_format { |old_format| old_format[15] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SaveData.register(:game_version) do
|
SaveData.register(:game_version) do
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ SaveData.register_conversion(:v20_add_stats) do
|
|||||||
to_all do |save_data|
|
to_all do |save_data|
|
||||||
unless save_data.has_key?(:stats)
|
unless save_data.has_key?(:stats)
|
||||||
save_data[:stats] = GameStats.new
|
save_data[:stats] = GameStats.new
|
||||||
save_data[:stats].play_time = save_data[:frame_count].to_f / Graphics.frame_rate
|
save_data[:stats].play_time = (save_data[:frame_count] || 0).to_f / Graphics.frame_rate
|
||||||
save_data[:stats].play_sessions = 1
|
save_data[:stats].play_sessions = 1
|
||||||
save_data[:stats].time_last_saved = save_data[:stats].play_time
|
save_data[:stats].time_last_saved = save_data[:stats].play_time
|
||||||
end
|
end
|
||||||
@@ -404,3 +404,13 @@ SaveData.register_conversion(:v21_replace_flute_booleans) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
SaveData.register_conversion(:v21_add_bump_stat) do
|
||||||
|
essentials_version 21
|
||||||
|
display_title "Adding a bump stat"
|
||||||
|
to_value :stats do |stats|
|
||||||
|
stats.instance_eval do
|
||||||
|
@bump_count = 0 if !@bump_count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -913,7 +913,7 @@ class Interpreter
|
|||||||
# * Screen Shake
|
# * Screen Shake
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
def command_225
|
def command_225
|
||||||
$game_screen.start_shake(@parameters[0], @parameters[1], @parameters[2] * Graphics.frame_rate / 20)
|
$game_screen.start_shake(@parameters[0], @parameters[1], @parameters[2])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ class Game_Screen
|
|||||||
@shake_power = 0
|
@shake_power = 0
|
||||||
@shake_speed = 0
|
@shake_speed = 0
|
||||||
@shake_duration = 0
|
@shake_duration = 0
|
||||||
@shake_direction = 1
|
|
||||||
@shake = 0
|
@shake = 0
|
||||||
@pictures = [nil]
|
@pictures = [nil]
|
||||||
(1..100).each { |i| @pictures.push(Game_Picture.new(i)) }
|
(1..100).each { |i| @pictures.push(Game_Picture.new(i)) }
|
||||||
@@ -57,16 +56,19 @@ class Game_Screen
|
|||||||
@flash_timer_start = $stats.play_time
|
@flash_timer_start = $stats.play_time
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# duration is time in 1/20ths of a second.
|
||||||
def start_shake(power, speed, duration)
|
def start_shake(power, speed, duration)
|
||||||
@shake_power = power
|
@shake_power = power
|
||||||
@shake_speed = speed
|
@shake_speed = speed
|
||||||
@shake_duration = duration
|
@shake_duration = duration / 20.0
|
||||||
|
@shake_timer_start = $stats.play_time
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# duration is time in 1/20ths of a second.
|
||||||
def weather(type, power, duration)
|
def weather(type, power, duration)
|
||||||
@weather_type = GameData::Weather.get(type).id
|
@weather_type = GameData::Weather.get(type).id
|
||||||
@weather_max = (power + 1) * RPG::Weather::MAX_SPRITES / 10
|
@weather_max = (power + 1) * RPG::Weather::MAX_SPRITES / 10
|
||||||
@weather_duration = duration # In 1/20ths of a seconds
|
@weather_duration = duration
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@@ -98,16 +100,25 @@ class Game_Screen
|
|||||||
@flash_timer_start = nil
|
@flash_timer_start = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if @shake_duration >= 1 || @shake != 0
|
if @shake_timer_start
|
||||||
delta = (@shake_power * @shake_speed * @shake_direction) / 10.0
|
delta_t = now - @shake_timer_start
|
||||||
if @shake_duration <= 1 && @shake * (@shake + delta) < 0
|
movement_per_second = @shake_power * @shake_speed * 4
|
||||||
@shake = 0
|
limit = @shake_power * 2.5 # Maximum pixel displacement
|
||||||
|
phase = (delta_t * movement_per_second / limit).to_i % 4
|
||||||
|
if phase == 0 || phase == 2
|
||||||
|
@shake = (movement_per_second * delta_t) % limit
|
||||||
|
@shake *= -1 if phase == 2
|
||||||
else
|
else
|
||||||
@shake += delta
|
@shake = limit - ((movement_per_second * delta_t) % limit)
|
||||||
|
@shake *= -1 if phase == 3
|
||||||
|
end
|
||||||
|
if delta_t >= @shake_duration
|
||||||
|
@shake_phase = phase if !@shake_phase || phase == 1 || phase == 3
|
||||||
|
if phase != @shake_phase || @shake < 2
|
||||||
|
@shake_timer_start = nil
|
||||||
|
@shake = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@shake_direction = -1 if @shake > @shake_power * 2
|
|
||||||
@shake_direction = 1 if @shake < -@shake_power * 2
|
|
||||||
@shake_duration -= 1 if @shake_duration >= 1
|
|
||||||
end
|
end
|
||||||
if $game_temp.in_battle
|
if $game_temp.in_battle
|
||||||
(51..100).each { |i| @pictures[i].update }
|
(51..100).each { |i| @pictures[i].update }
|
||||||
@@ -130,5 +141,5 @@ def pbFlash(color, frames)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pbShake(power, speed, frames)
|
def pbShake(power, speed, frames)
|
||||||
$game_screen.start_shake(power, speed, frames * Graphics.frame_rate / 20)
|
$game_screen.start_shake(power, speed, frames)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ class Game_Map
|
|||||||
(1...$data_common_events.size).each do |i|
|
(1...$data_common_events.size).each do |i|
|
||||||
@common_events[i] = Game_CommonEvent.new(i)
|
@common_events[i] = Game_CommonEvent.new(i)
|
||||||
end
|
end
|
||||||
@scroll_direction = 2
|
@scroll_distance_x = 0
|
||||||
@scroll_rest = 0
|
@scroll_distance_y = 0
|
||||||
@scroll_speed = 4
|
@scroll_speed = 4
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -356,18 +356,42 @@ class Game_Map
|
|||||||
self.display_x += distance
|
self.display_x += distance
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_scroll(direction, distance, speed)
|
# speed is:
|
||||||
@scroll_direction = direction
|
# 1: moves 1 tile in 1.6 seconds
|
||||||
if [2, 8].include?(direction) # down or up
|
# 2: moves 1 tile in 0.8 seconds
|
||||||
@scroll_rest = distance * REAL_RES_Y
|
# 3: moves 1 tile in 0.4 seconds
|
||||||
else
|
# 4: moves 1 tile in 0.2 seconds
|
||||||
@scroll_rest = distance * REAL_RES_X
|
# 5: moves 1 tile in 0.1 seconds
|
||||||
|
# 6: moves 1 tile in 0.05 seconds
|
||||||
|
def start_scroll(direction, distance, speed = 4)
|
||||||
|
return if direction <= 0 || direction == 5 || direction >= 10
|
||||||
|
if [1, 3, 4, 6, 7, 9].include(direction) # horizontal
|
||||||
|
@scroll_distance_x = distance
|
||||||
|
@scroll_distance_x *= -1 if [1, 4, 7].include?(direction)
|
||||||
|
end
|
||||||
|
if [1, 2, 3, 7, 8, 9].include?(direction) # vertical
|
||||||
|
@scroll_distance_y = distance
|
||||||
|
@scroll_distance_y *= -1 if [7, 8, 9].include?(direction)
|
||||||
end
|
end
|
||||||
@scroll_speed = speed
|
@scroll_speed = speed
|
||||||
|
@scroll_start_x = display_x
|
||||||
|
@scroll_start_y = display_y
|
||||||
|
@scroll_timer_start = System.uptime
|
||||||
|
end
|
||||||
|
|
||||||
|
# The two distances can be positive or negative.
|
||||||
|
def start_scroll_custom(distance_x, distance_y, speed = 4)
|
||||||
|
return if distance_x == 0 && distance_y == 0
|
||||||
|
@scroll_distance_x = distance_x
|
||||||
|
@scroll_distance_y = distance_y
|
||||||
|
@scroll_speed = speed
|
||||||
|
@scroll_start_x = display_x
|
||||||
|
@scroll_start_y = display_y
|
||||||
|
@scroll_timer_start = System.uptime
|
||||||
end
|
end
|
||||||
|
|
||||||
def scrolling?
|
def scrolling?
|
||||||
return @scroll_rest > 0
|
return (@scroll_distance_x || 0) != 0 || (@scroll_distance_y || 0) != 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# duration is time in 1/20ths of a second.
|
# duration is time in 1/20ths of a second.
|
||||||
@@ -419,16 +443,17 @@ class Game_Map
|
|||||||
$map_factory.setCurrentMap
|
$map_factory.setCurrentMap
|
||||||
end
|
end
|
||||||
# If scrolling
|
# If scrolling
|
||||||
if @scroll_rest > 0
|
if (@scroll_distance_x || 0) != 0
|
||||||
distance = (1 << @scroll_speed) * 40.0 / Graphics.frame_rate
|
duration = @scroll_distance_x.abs * TILE_WIDTH.to_f / (10 * (2**@scroll_speed))
|
||||||
distance = @scroll_rest if distance > @scroll_rest
|
scroll_offset = lerp(0, @scroll_distance_x, duration, @scroll_timer_start, System.uptime)
|
||||||
case @scroll_direction
|
self.display_x = @scroll_start_x + scroll_offset * REAL_RES_X
|
||||||
when 2 then scroll_down(distance)
|
@scroll_distance_x = 0 if scroll_offset == @scroll_distance_x
|
||||||
when 4 then scroll_left(distance)
|
|
||||||
when 6 then scroll_right(distance)
|
|
||||||
when 8 then scroll_up(distance)
|
|
||||||
end
|
end
|
||||||
@scroll_rest -= distance
|
if (@scroll_distance_y || 0) != 0
|
||||||
|
duration = @scroll_distance_y.abs * TILE_HEIGHT.to_f / (10 * (2**@scroll_speed))
|
||||||
|
scroll_offset = lerp(0, @scroll_distance_y, duration, @scroll_timer_start, System.uptime)
|
||||||
|
self.display_y = @scroll_start_y + scroll_offset * REAL_RES_Y
|
||||||
|
@scroll_distance_y = 0 if scroll_offset == @scroll_distance_y
|
||||||
end
|
end
|
||||||
# Only update events that are on-screen
|
# Only update events that are on-screen
|
||||||
if !$game_temp.in_menu
|
if !$game_temp.in_menu
|
||||||
@@ -463,26 +488,74 @@ end
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbScrollMap(direction, distance, speed)
|
# Scroll the map in the given direction by the given distance at the (optional)
|
||||||
|
# given speed.
|
||||||
|
def pbScrollMap(direction, distance, speed = 4)
|
||||||
if speed == 0
|
if speed == 0
|
||||||
case direction
|
if [1, 2, 3].include?(direction)
|
||||||
when 2 then $game_map.scroll_down(distance * Game_Map::REAL_RES_Y)
|
$game_map.scroll_down(distance * Game_Map::REAL_RES_Y)
|
||||||
when 4 then $game_map.scroll_left(distance * Game_Map::REAL_RES_X)
|
elsif [7, 8, 9].include?(direction)
|
||||||
when 6 then $game_map.scroll_right(distance * Game_Map::REAL_RES_X)
|
$game_map.scroll_up(distance * Game_Map::REAL_RES_Y)
|
||||||
when 8 then $game_map.scroll_up(distance * Game_Map::REAL_RES_Y)
|
end
|
||||||
|
if [3, 6, 9].include?(direction)
|
||||||
|
$game_map.scroll_right(distance * Game_Map::REAL_RES_X)
|
||||||
|
elsif [1, 4, 7].include?(direction)
|
||||||
|
$game_map.scroll_left(distance * Game_Map::REAL_RES_X)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
$game_map.start_scroll(direction, distance, speed)
|
$game_map.start_scroll(direction, distance, speed)
|
||||||
oldx = $game_map.display_x
|
|
||||||
oldy = $game_map.display_y
|
|
||||||
loop do
|
loop do
|
||||||
Graphics.update
|
Graphics.update
|
||||||
Input.update
|
Input.update
|
||||||
break if !$game_map.scrolling?
|
|
||||||
pbUpdateSceneMap
|
pbUpdateSceneMap
|
||||||
break if $game_map.display_x == oldx && $game_map.display_y == oldy
|
break if !$game_map.scrolling?
|
||||||
oldx = $game_map.display_x
|
|
||||||
oldy = $game_map.display_y
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Scroll the map to center on the given coordinates at the (optional) given
|
||||||
|
# speed. The scroll can happen in up to two parts, depending on where the target
|
||||||
|
# is relative to the current location: an initial diagonal movement and a
|
||||||
|
# following cardinal (vertical/horizontal) movement.
|
||||||
|
def pbScrollMapTo(x, y, speed = 4)
|
||||||
|
if !$game_map.valid?(x, y)
|
||||||
|
print "pbScrollMapTo: given x,y is invalid"
|
||||||
|
return
|
||||||
|
elsif !(0..6).include?(speed)
|
||||||
|
print "pbScrollMapTo: invalid speed (0-6 only)"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
# Get tile coordinates that the screen is currently scrolled to
|
||||||
|
screen_offset_x = (Graphics.width - Game_Map::TILE_WIDTH) * Game_Map::X_SUBPIXELS / 2
|
||||||
|
screen_offset_y = (Graphics.height - Game_Map::TILE_HEIGHT) * Game_Map::Y_SUBPIXELS / 2
|
||||||
|
current_tile_x = ($game_map.display_x + screen_offset_x) / Game_Map::REAL_RES_X
|
||||||
|
current_tile_y = ($game_map.display_y + screen_offset_y) / Game_Map::REAL_RES_Y
|
||||||
|
offset_x = x - current_tile_x
|
||||||
|
offset_y = y - current_tile_y
|
||||||
|
return if offset_x == 0 && offset_y == 0
|
||||||
|
if speed == 0
|
||||||
|
if offset_y > 0
|
||||||
|
$game_map.scroll_down(offset_y.abs * Game_Map::REAL_RES_Y)
|
||||||
|
elsif offset_y < 0
|
||||||
|
$game_map.scroll_up(offset_y.abs * Game_Map::REAL_RES_Y)
|
||||||
|
end
|
||||||
|
if offset_x > 0
|
||||||
|
$game_map.scroll_right(offset_x.abs * Game_Map::REAL_RES_X)
|
||||||
|
elsif offset_x < 0
|
||||||
|
$game_map.scroll_left(offset_x.abs * Game_Map::REAL_RES_X)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
$game_map.start_scroll_custom(offset_x, offset_y, speed)
|
||||||
|
loop do
|
||||||
|
Graphics.update
|
||||||
|
Input.update
|
||||||
|
pbUpdateSceneMap
|
||||||
|
break if !$game_map.scrolling?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Scroll the map to center on the player at the (optional) given speed.
|
||||||
|
def pbScrollMapToPlayer(speed = 4)
|
||||||
|
pbScrollMapTo($game_player.x, $game_player.y, speed)
|
||||||
|
end
|
||||||
|
|||||||
@@ -1,189 +0,0 @@
|
|||||||
#===============================================================================
|
|
||||||
# ** Map Autoscroll
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# Wachunga
|
|
||||||
# Version 1.02
|
|
||||||
# 2005-12-18
|
|
||||||
#===============================================================================
|
|
||||||
#
|
|
||||||
# This script supplements the built-in "Scroll Map" event command with the
|
|
||||||
# aim of simplifying cutscenes (and map scrolling in general). Whereas the
|
|
||||||
# normal event command requires a direction and number of tiles to scroll,
|
|
||||||
# Map Autoscroll scrolls the map to center on the tile whose x and y
|
|
||||||
# coordinates are given.
|
|
||||||
#
|
|
||||||
# FEATURES
|
|
||||||
# - automatic map scrolling to given x,y coordinate (or player)
|
|
||||||
# - destination is fixed, so it's possible to scroll to same place even if
|
|
||||||
# origin is variable (e.g. moving NPC)
|
|
||||||
# - variable speed (just like "Scroll Map" event command)
|
|
||||||
# - diagonal scrolling supported
|
|
||||||
#
|
|
||||||
# SETUP
|
|
||||||
# Instead of a "Scroll Map" event command, use the "Call Script" command
|
|
||||||
# and enter on the following on the first line:
|
|
||||||
#
|
|
||||||
# autoscroll(x,y)
|
|
||||||
#
|
|
||||||
# (replacing "x" and "y" with the x and y coordinates of the tile to scroll to)
|
|
||||||
#
|
|
||||||
# To specify a scroll speed other than the default (4), use:
|
|
||||||
#
|
|
||||||
# autoscroll(x,y,speed)
|
|
||||||
#
|
|
||||||
# (now also replacing "speed" with the scroll speed from 1-6)
|
|
||||||
#
|
|
||||||
# Diagonal scrolling happens automatically when the destination is diagonal
|
|
||||||
# relative to the starting point (i.e., not directly up, down, left or right).
|
|
||||||
#
|
|
||||||
# To scroll to the player, instead use the following:
|
|
||||||
#
|
|
||||||
# autoscroll_player(speed)
|
|
||||||
#
|
|
||||||
# Note: because of how the interpreter and the "Call Script" event command
|
|
||||||
# are setup, the call to autoscroll(...) can only be on the first line of
|
|
||||||
# the "Call Script" event command (and not flowing down to subsequent lines).
|
|
||||||
#
|
|
||||||
# For example, the following call may not work as expected:
|
|
||||||
#
|
|
||||||
# autoscroll($game_variables[1],
|
|
||||||
# $game_variables[2])
|
|
||||||
#
|
|
||||||
# (since the long argument names require dropping down to a second line)
|
|
||||||
# A work-around is to setup new variables with shorter names in a preceding
|
|
||||||
# (separate) "Call Script" event command:
|
|
||||||
#
|
|
||||||
# @x = $game_variables[1]
|
|
||||||
# @y = $game_variables[2]
|
|
||||||
#
|
|
||||||
# and then use those as arguments:
|
|
||||||
#
|
|
||||||
# autoscroll(@x,@y)
|
|
||||||
#
|
|
||||||
# The renaming must be in a separate "Call Script" because otherwise
|
|
||||||
# the call to autoscroll(...) isn't on the first line.
|
|
||||||
#
|
|
||||||
# Originally requested by militantmilo80:
|
|
||||||
# http://www.rmxp.net/forums/index.php?showtopic=29519
|
|
||||||
#
|
|
||||||
#===============================================================================
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
#
|
|
||||||
#===============================================================================
|
|
||||||
class Interpreter
|
|
||||||
SCROLL_SPEED_DEFAULT = 4
|
|
||||||
# Map Autoscroll to Coordinates
|
|
||||||
# x : x coordinate to scroll to and center on
|
|
||||||
# y : y coordinate to scroll to and center on
|
|
||||||
# speed : (optional) scroll speed (from 1-6, default being 4)
|
|
||||||
def autoscroll(x, y, speed = SCROLL_SPEED_DEFAULT)
|
|
||||||
if $game_map.scrolling?
|
|
||||||
return false
|
|
||||||
elsif !$game_map.valid?(x, y)
|
|
||||||
print "Map Autoscroll: given x,y is invalid"
|
|
||||||
return command_skip
|
|
||||||
elsif !(1..6).include?(speed)
|
|
||||||
print "Map Autoscroll: invalid speed (1-6 only)"
|
|
||||||
return command_skip
|
|
||||||
end
|
|
||||||
center_x = ((Graphics.width / 2) - (Game_Map::TILE_WIDTH / 2)) * 4 # X coordinate in the center of the screen
|
|
||||||
center_y = ((Graphics.height / 2) - (Game_Map::TILE_HEIGHT / 2)) * 4 # Y coordinate in the center of the screen
|
|
||||||
max_x = ($game_map.width - (Graphics.width.to_f / Game_Map::TILE_WIDTH)) * 4 * Game_Map::TILE_WIDTH
|
|
||||||
max_y = ($game_map.height - (Graphics.height.to_f / Game_Map::TILE_HEIGHT)) * 4 * Game_Map::TILE_HEIGHT
|
|
||||||
count_x = ($game_map.display_x - [0, [(x * Game_Map::REAL_RES_X) - center_x, max_x].min].max) / Game_Map::REAL_RES_X
|
|
||||||
count_y = ($game_map.display_y - [0, [(y * Game_Map::REAL_RES_Y) - center_y, max_y].min].max) / Game_Map::REAL_RES_Y
|
|
||||||
if @diag
|
|
||||||
@diag = false
|
|
||||||
dir = nil
|
|
||||||
if count_x != 0 && count_y != 0
|
|
||||||
return false
|
|
||||||
elsif count_x > 0
|
|
||||||
dir = 4
|
|
||||||
elsif count_x < 0
|
|
||||||
dir = 6
|
|
||||||
elsif count_y > 0
|
|
||||||
dir = 8
|
|
||||||
elsif count_y < 0
|
|
||||||
dir = 2
|
|
||||||
end
|
|
||||||
count = count_x == 0 ? count_y.abs : count_x.abs
|
|
||||||
else
|
|
||||||
@diag = true
|
|
||||||
dir = nil
|
|
||||||
if count_x > 0
|
|
||||||
if count_y > 0
|
|
||||||
dir = 7
|
|
||||||
elsif count_y < 0
|
|
||||||
dir = 1
|
|
||||||
end
|
|
||||||
elsif count_x < 0
|
|
||||||
if count_y > 0
|
|
||||||
dir = 9
|
|
||||||
elsif count_y < 0
|
|
||||||
dir = 3
|
|
||||||
end
|
|
||||||
end
|
|
||||||
count = [count_x.abs, count_y.abs].min
|
|
||||||
end
|
|
||||||
$game_map.start_scroll(dir, count, speed) if dir
|
|
||||||
return !@diag
|
|
||||||
end
|
|
||||||
|
|
||||||
# Map Autoscroll (to Player)
|
|
||||||
# speed : (optional) scroll speed (from 1-6, default being 4)
|
|
||||||
def autoscroll_player(speed = SCROLL_SPEED_DEFAULT)
|
|
||||||
autoscroll($game_player.x, $game_player.y, speed)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
#
|
|
||||||
#===============================================================================
|
|
||||||
class Game_Map
|
|
||||||
def scroll_downright(distance)
|
|
||||||
@display_x = [@display_x + distance,
|
|
||||||
(self.width - (Graphics.width.to_f / TILE_WIDTH)) * REAL_RES_X].min
|
|
||||||
@display_y = [@display_y + distance,
|
|
||||||
(self.height - (Graphics.height.to_f / TILE_HEIGHT)) * REAL_RES_Y].min
|
|
||||||
end
|
|
||||||
|
|
||||||
def scroll_downleft(distance)
|
|
||||||
@display_x = [@display_x - distance, 0].max
|
|
||||||
@display_y = [@display_y + distance,
|
|
||||||
(self.height - (Graphics.height.to_f / TILE_HEIGHT)) * REAL_RES_Y].min
|
|
||||||
end
|
|
||||||
|
|
||||||
def scroll_upright(distance)
|
|
||||||
@display_x = [@display_x + distance,
|
|
||||||
(self.width - (Graphics.width.to_f / TILE_WIDTH)) * REAL_RES_X].min
|
|
||||||
@display_y = [@display_y - distance, 0].max
|
|
||||||
end
|
|
||||||
|
|
||||||
def scroll_upleft(distance)
|
|
||||||
@display_x = [@display_x - distance, 0].max
|
|
||||||
@display_y = [@display_y - distance, 0].max
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_scrolling
|
|
||||||
# If scrolling
|
|
||||||
if @scroll_rest > 0
|
|
||||||
# Change from scroll speed to distance in map coordinates
|
|
||||||
distance = (1 << @scroll_speed) * 40 / Graphics.frame_rate
|
|
||||||
distance = @scroll_rest if distance > @scroll_rest
|
|
||||||
# Execute scrolling
|
|
||||||
case @scroll_direction
|
|
||||||
when 1 then scroll_downleft(distance)
|
|
||||||
when 2 then scroll_down(distance)
|
|
||||||
when 3 then scroll_downright(distance)
|
|
||||||
when 4 then scroll_left(distance)
|
|
||||||
when 6 then scroll_right(distance)
|
|
||||||
when 7 then scroll_upleft(distance)
|
|
||||||
when 8 then scroll_up(distance)
|
|
||||||
when 9 then scroll_upright(distance)
|
|
||||||
end
|
|
||||||
# Subtract distance scrolled
|
|
||||||
@scroll_rest -= distance
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -72,6 +72,7 @@ class Game_Character
|
|||||||
@always_on_top = false
|
@always_on_top = false
|
||||||
@anime_count = 0 # Time since pattern was last changed
|
@anime_count = 0 # Time since pattern was last changed
|
||||||
@stop_count = 0 # Time since character last finished moving
|
@stop_count = 0 # Time since character last finished moving
|
||||||
|
@bumping = false # Used by the player only when walking into something
|
||||||
@jump_peak = 0 # Max height while jumping
|
@jump_peak = 0 # Max height while jumping
|
||||||
@jump_distance = 0 # Total distance of jump
|
@jump_distance = 0 # Total distance of jump
|
||||||
@jump_fraction = 0 # How far through a jump we currently are (0-1)
|
@jump_fraction = 0 # How far through a jump we currently are (0-1)
|
||||||
@@ -337,8 +338,7 @@ class Game_Character
|
|||||||
# Movement
|
# Movement
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
def moving?
|
def moving?
|
||||||
return @real_x != @x * Game_Map::REAL_RES_X ||
|
return !@move_timer.nil?
|
||||||
@real_y != @y * Game_Map::REAL_RES_Y
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def jumping?
|
def jumping?
|
||||||
@@ -955,8 +955,10 @@ class Game_Character
|
|||||||
@real_x = @x * Game_Map::REAL_RES_X if (@real_x - (@x * Game_Map::REAL_RES_X)).abs < Game_Map::X_SUBPIXELS / 2
|
@real_x = @x * Game_Map::REAL_RES_X if (@real_x - (@x * Game_Map::REAL_RES_X)).abs < Game_Map::X_SUBPIXELS / 2
|
||||||
@real_y = @y * Game_Map::REAL_RES_Y if (@real_y - (@y * Game_Map::REAL_RES_Y)).abs < Game_Map::Y_SUBPIXELS / 2
|
@real_y = @y * Game_Map::REAL_RES_Y if (@real_y - (@y * Game_Map::REAL_RES_Y)).abs < Game_Map::Y_SUBPIXELS / 2
|
||||||
# End of move
|
# End of move
|
||||||
if !moving?
|
if moving? && @move_timer >= @move_time &&
|
||||||
|
@real_x == @x * Game_Map::REAL_RES_X && @real_y == @y * Game_Map::REAL_RES_Y
|
||||||
@move_timer = nil
|
@move_timer = nil
|
||||||
|
@bumping = false
|
||||||
end
|
end
|
||||||
# End of jump
|
# End of jump
|
||||||
if jumping? && @jump_fraction >= 1
|
if jumping? && @jump_fraction >= 1
|
||||||
@@ -6,20 +6,19 @@
|
|||||||
# instance of this class.
|
# instance of this class.
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class Game_Player < Game_Character
|
class Game_Player < Game_Character
|
||||||
attr_accessor :bump_se
|
|
||||||
attr_accessor :charsetData
|
attr_accessor :charsetData
|
||||||
attr_accessor :encounter_count
|
attr_accessor :encounter_count
|
||||||
|
|
||||||
SCREEN_CENTER_X = ((Settings::SCREEN_WIDTH / 2) - (Game_Map::TILE_WIDTH / 2)) * Game_Map::X_SUBPIXELS
|
SCREEN_CENTER_X = ((Settings::SCREEN_WIDTH / 2) - (Game_Map::TILE_WIDTH / 2)) * Game_Map::X_SUBPIXELS
|
||||||
SCREEN_CENTER_Y = ((Settings::SCREEN_HEIGHT / 2) - (Game_Map::TILE_HEIGHT / 2)) * Game_Map::Y_SUBPIXELS
|
SCREEN_CENTER_Y = ((Settings::SCREEN_HEIGHT / 2) - (Game_Map::TILE_HEIGHT / 2)) * Game_Map::Y_SUBPIXELS
|
||||||
|
# Time in seconds for one cycle of bobbing (playing 4 charset frames) while
|
||||||
@@bobFrameSpeed = 1.0 / 15
|
# surfing or diving.
|
||||||
|
SURF_BOB_DURATION = 1.5
|
||||||
|
|
||||||
def initialize(*arg)
|
def initialize(*arg)
|
||||||
super(*arg)
|
super(*arg)
|
||||||
@lastdir = 0
|
@lastdir = 0
|
||||||
@lastdirframe = 0
|
@lastdirframe = 0
|
||||||
@bump_se = 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def map
|
def map
|
||||||
@@ -52,6 +51,7 @@ class Game_Player < Game_Character
|
|||||||
|
|
||||||
def can_run?
|
def can_run?
|
||||||
return @move_speed > 3 if @move_route_forcing
|
return @move_speed > 3 if @move_route_forcing
|
||||||
|
return false if @bumping
|
||||||
return false if $game_temp.in_menu || $game_temp.in_battle ||
|
return false if $game_temp.in_menu || $game_temp.in_battle ||
|
||||||
$game_temp.message_window_showing || pbMapInterpreterRunning?
|
$game_temp.message_window_showing || pbMapInterpreterRunning?
|
||||||
return false if !$player.has_running_shoes && !$PokemonGlobal.diving &&
|
return false if !$player.has_running_shoes && !$PokemonGlobal.diving &&
|
||||||
@@ -92,6 +92,7 @@ class Game_Player < Game_Character
|
|||||||
self.move_speed = 3 if !@move_route_forcing
|
self.move_speed = 3 if !@move_route_forcing
|
||||||
new_charset = pbGetPlayerCharset(meta.walk_charset)
|
new_charset = pbGetPlayerCharset(meta.walk_charset)
|
||||||
end
|
end
|
||||||
|
self.move_speed = 3 if @bumping
|
||||||
@character_name = new_charset if new_charset
|
@character_name = new_charset if new_charset
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -115,9 +116,12 @@ class Game_Player < Game_Character
|
|||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
|
||||||
def bump_into_object
|
def bump_into_object
|
||||||
return if @bump_se && @bump_se > 0
|
|
||||||
pbSEPlay("Player bump") if !@move_route_forcing
|
pbSEPlay("Player bump") if !@move_route_forcing
|
||||||
@bump_se = Graphics.frame_rate / 4
|
$stats.bump_count += 1
|
||||||
|
@move_initial_x = @x
|
||||||
|
@move_initial_y = @y
|
||||||
|
@move_timer = 0.0
|
||||||
|
@bumping = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_move_distance_to_stats(distance = 1)
|
def add_move_distance_to_stats(distance = 1)
|
||||||
@@ -412,8 +416,6 @@ class Game_Player < Game_Character
|
|||||||
$game_temp.followers.move_followers
|
$game_temp.followers.move_followers
|
||||||
end
|
end
|
||||||
$game_temp.followers.update
|
$game_temp.followers.update
|
||||||
# Count down the time between allowed bump sounds
|
|
||||||
@bump_se -= 1 if @bump_se && @bump_se > 0
|
|
||||||
update_event_triggering
|
update_event_triggering
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -425,7 +427,7 @@ class Game_Player < Game_Character
|
|||||||
!$game_temp.in_mini_update && !$game_temp.in_menu
|
!$game_temp.in_mini_update && !$game_temp.in_menu
|
||||||
# Move player in the direction the directional button is being pressed
|
# Move player in the direction the directional button is being pressed
|
||||||
if @moved_last_frame ||
|
if @moved_last_frame ||
|
||||||
(dir > 0 && dir == @lastdir && Graphics.frame_count - @lastdirframe > Graphics.frame_rate / 20)
|
(dir > 0 && dir == @lastdir && System.uptime - @lastdirframe >= 0.075)
|
||||||
case dir
|
case dir
|
||||||
when 2 then move_down
|
when 2 then move_down
|
||||||
when 4 then move_left
|
when 4 then move_left
|
||||||
@@ -440,11 +442,11 @@ class Game_Player < Game_Character
|
|||||||
when 8 then turn_up
|
when 8 then turn_up
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
# Record last direction input
|
# Record last direction input
|
||||||
@lastdirframe = Graphics.frame_count if dir != @lastdir
|
@lastdirframe = System.uptime if dir != @lastdir
|
||||||
@lastdir = dir
|
@lastdir = dir
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def update_move
|
def update_move
|
||||||
if !@moved_last_frame || @stopped_last_frame # Started a new step
|
if !@moved_last_frame || @stopped_last_frame # Started a new step
|
||||||
@@ -501,10 +503,10 @@ class Game_Player < Game_Character
|
|||||||
|
|
||||||
def update_pattern
|
def update_pattern
|
||||||
if $PokemonGlobal&.surfing || $PokemonGlobal&.diving
|
if $PokemonGlobal&.surfing || $PokemonGlobal&.diving
|
||||||
p = ((Graphics.frame_count % 60) * @@bobFrameSpeed).floor
|
bob_pattern = (4 * System.uptime / SURF_BOB_DURATION).to_i % 4
|
||||||
@pattern = p if !@lock_pattern
|
@pattern = bob_pattern if !@lock_pattern
|
||||||
@pattern_surf = p
|
@pattern_surf = bob_pattern
|
||||||
@bob_height = (p >= 2) ? 2 : 0
|
@bob_height = (bob_pattern >= 2) ? 2 : 0
|
||||||
@anime_count = 0
|
@anime_count = 0
|
||||||
else
|
else
|
||||||
@bob_height = 0
|
@bob_height = 0
|
||||||
@@ -5,6 +5,7 @@ class GameStats
|
|||||||
# Travel
|
# Travel
|
||||||
attr_accessor :distance_walked, :distance_cycled, :distance_surfed # surfed includes diving
|
attr_accessor :distance_walked, :distance_cycled, :distance_surfed # surfed includes diving
|
||||||
attr_accessor :distance_slid_on_ice # Also counted in distance_walked
|
attr_accessor :distance_slid_on_ice # Also counted in distance_walked
|
||||||
|
attr_accessor :bump_count # Times the player walked into something
|
||||||
attr_accessor :cycle_count, :surf_count, :dive_count
|
attr_accessor :cycle_count, :surf_count, :dive_count
|
||||||
# Field actions
|
# Field actions
|
||||||
attr_accessor :fly_count, :cut_count, :flash_count
|
attr_accessor :fly_count, :cut_count, :flash_count
|
||||||
@@ -45,7 +46,7 @@ class GameStats
|
|||||||
attr_accessor :mart_items_bought, :premier_balls_earned
|
attr_accessor :mart_items_bought, :premier_balls_earned
|
||||||
attr_accessor :drinks_bought, :drinks_won # From vending machines
|
attr_accessor :drinks_bought, :drinks_won # From vending machines
|
||||||
attr_accessor :coins_won, :coins_lost # Not bought, not spent
|
attr_accessor :coins_won, :coins_lost # Not bought, not spent
|
||||||
attr_accessor :battle_points_won, :battle_points_spent # Currently unused
|
attr_accessor :battle_points_won, :battle_points_spent
|
||||||
attr_accessor :soot_collected
|
attr_accessor :soot_collected
|
||||||
# Special stats
|
# Special stats
|
||||||
attr_accessor :gym_leader_attempts # An array of integers
|
attr_accessor :gym_leader_attempts # An array of integers
|
||||||
@@ -66,6 +67,7 @@ class GameStats
|
|||||||
@distance_cycled = 0
|
@distance_cycled = 0
|
||||||
@distance_surfed = 0
|
@distance_surfed = 0
|
||||||
@distance_slid_on_ice = 0
|
@distance_slid_on_ice = 0
|
||||||
|
@bump_count = 0
|
||||||
@cycle_count = 0
|
@cycle_count = 0
|
||||||
@surf_count = 0
|
@surf_count = 0
|
||||||
@dive_count = 0
|
@dive_count = 0
|
||||||
@@ -170,8 +172,9 @@ class GameStats
|
|||||||
|
|
||||||
def play_time
|
def play_time
|
||||||
if $game_temp&.last_uptime_refreshed_play_time
|
if $game_temp&.last_uptime_refreshed_play_time
|
||||||
@play_time += System.uptime - $game_temp.last_uptime_refreshed_play_time
|
now = System.uptime
|
||||||
$game_temp.last_uptime_refreshed_play_time = System.uptime
|
@play_time += now - $game_temp.last_uptime_refreshed_play_time
|
||||||
|
$game_temp.last_uptime_refreshed_play_time = now
|
||||||
end
|
end
|
||||||
return @play_time
|
return @play_time
|
||||||
end
|
end
|
||||||
@@ -66,9 +66,8 @@ class Sprite_Reflection
|
|||||||
@sprite.z = -50 # Still water is -100, map is 0 and above
|
@sprite.z = -50 # Still water is -100, map is 0 and above
|
||||||
@sprite.z += 1 if event == $game_player
|
@sprite.z += 1 if event == $game_player
|
||||||
@sprite.zoom_x = @parent_sprite.zoom_x
|
@sprite.zoom_x = @parent_sprite.zoom_x
|
||||||
|
@sprite.zoom_x += 0.05 * @sprite.zoom_x * Math.sin(2 * Math::PI * System.uptime)
|
||||||
@sprite.zoom_y = @parent_sprite.zoom_y
|
@sprite.zoom_y = @parent_sprite.zoom_y
|
||||||
frame = (Graphics.frame_count % 40) / 10
|
|
||||||
@sprite.zoom_x *= [1.0, 0.95, 1.0, 1.05][frame]
|
|
||||||
@sprite.angle = 180.0
|
@sprite.angle = 180.0
|
||||||
@sprite.mirror = true
|
@sprite.mirror = true
|
||||||
@sprite.bitmap = @parent_sprite.bitmap
|
@sprite.bitmap = @parent_sprite.bitmap
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ class Window
|
|||||||
@cursoropacity = 128
|
@cursoropacity = 128
|
||||||
end
|
end
|
||||||
if @pause
|
if @pause
|
||||||
@pauseframe = (Graphics.frame_count / 8) % 4
|
@pauseframe = (System.uptime * 5).to_i % 4 # 4 frames, 5 frames per second
|
||||||
@pauseopacity = [@pauseopacity + 64, 255].min
|
@pauseopacity = [@pauseopacity + 64, 255].min
|
||||||
mustchange = true
|
mustchange = true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ class SpriteWindow < Window
|
|||||||
if @pause
|
if @pause
|
||||||
oldpauseframe = @pauseframe
|
oldpauseframe = @pauseframe
|
||||||
oldpauseopacity = @pauseopacity
|
oldpauseopacity = @pauseopacity
|
||||||
@pauseframe = (Graphics.frame_count / 8) % 4
|
@pauseframe = (System.uptime * 5) % 4 # 4 frames, 5 frames per second
|
||||||
@pauseopacity = [@pauseopacity + 64, 255].min
|
@pauseopacity = [@pauseopacity + 64, 255].min
|
||||||
mustchange = @pauseframe != oldpauseframe || @pauseopacity != oldpauseopacity
|
mustchange = @pauseframe != oldpauseframe || @pauseopacity != oldpauseopacity
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
|||||||
|
|
||||||
def waitcount=(value)
|
def waitcount=(value)
|
||||||
@waitcount = (value <= 0) ? 0 : value
|
@waitcount = (value <= 0) ? 0 : value
|
||||||
|
@wait_timer_start = System.uptime if !@wait_timer_start && value > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :cursorMode
|
attr_reader :cursorMode
|
||||||
@@ -283,6 +284,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
|||||||
|
|
||||||
def setText(value)
|
def setText(value)
|
||||||
@waitcount = 0
|
@waitcount = 0
|
||||||
|
@wait_timer_start = nil
|
||||||
@curchar = 0
|
@curchar = 0
|
||||||
@drawncurchar = -1
|
@drawncurchar = -1
|
||||||
@lastDrawnChar = -1
|
@lastDrawnChar = -1
|
||||||
@@ -573,9 +575,12 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
|||||||
def update
|
def update
|
||||||
super
|
super
|
||||||
@pausesprite.update if @pausesprite&.visible
|
@pausesprite.update if @pausesprite&.visible
|
||||||
if @waitcount > 0
|
if @wait_timer_start
|
||||||
@waitcount -= 1
|
if System.uptime - @wait_timer_start >= @waitcount
|
||||||
return
|
@wait_timer_start = nil
|
||||||
|
@waitcount = 0
|
||||||
|
end
|
||||||
|
return if @wait_timer_start
|
||||||
end
|
end
|
||||||
if busy?
|
if busy?
|
||||||
refresh if !@frameskipChanged
|
refresh if !@frameskipChanged
|
||||||
|
|||||||
@@ -421,7 +421,6 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
msgwindow.waitcount = 0
|
msgwindow.waitcount = 0
|
||||||
autoresume = false
|
autoresume = false
|
||||||
text = message.clone
|
text = message.clone
|
||||||
msgback = nil
|
|
||||||
linecount = (Graphics.height > 400) ? 3 : 2
|
linecount = (Graphics.height > 400) ? 3 : 2
|
||||||
### Text replacement
|
### Text replacement
|
||||||
text.gsub!(/\\sign\[([^\]]*)\]/i) do # \sign[something] gets turned into
|
text.gsub!(/\\sign\[([^\]]*)\]/i) do # \sign[something] gets turned into
|
||||||
@@ -508,8 +507,8 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
controls[i][2] = textlen
|
controls[i][2] = textlen
|
||||||
end
|
end
|
||||||
text = textchunks.join
|
text = textchunks.join
|
||||||
signWaitCount = 0
|
appear_timer_start = nil
|
||||||
signWaitTime = Graphics.frame_rate / 2
|
appear_duration = 0.5 # In seconds
|
||||||
haveSpecialClose = false
|
haveSpecialClose = false
|
||||||
specialCloseSE = ""
|
specialCloseSE = ""
|
||||||
startSE = nil
|
startSE = nil
|
||||||
@@ -518,7 +517,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
param = controls[i][1]
|
param = controls[i][1]
|
||||||
case control
|
case control
|
||||||
when "op"
|
when "op"
|
||||||
signWaitCount = signWaitTime + 1
|
appear_timer_start = System.uptime
|
||||||
when "cl"
|
when "cl"
|
||||||
text = text.sub(/\001\z/, "") # fix: '$' can match end of line as well
|
text = text.sub(/\001\z/, "") # fix: '$' can match end of line as well
|
||||||
haveSpecialClose = true
|
haveSpecialClose = true
|
||||||
@@ -548,7 +547,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
end
|
end
|
||||||
if startSE
|
if startSE
|
||||||
pbSEPlay(pbStringToAudioFile(startSE))
|
pbSEPlay(pbStringToAudioFile(startSE))
|
||||||
elsif signWaitCount == 0 && letterbyletter
|
elsif !appear_timer_start && letterbyletter
|
||||||
pbPlayDecisionSE
|
pbPlayDecisionSE
|
||||||
end
|
end
|
||||||
# Position message window
|
# Position message window
|
||||||
@@ -561,15 +560,12 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
atTop = (msgwindow.y == 0)
|
atTop = (msgwindow.y == 0)
|
||||||
# Show text
|
# Show text
|
||||||
msgwindow.text = text
|
msgwindow.text = text
|
||||||
Graphics.frame_reset if Graphics.frame_rate > 40
|
|
||||||
loop do
|
loop do
|
||||||
if signWaitCount > 0
|
if appear_timer_start
|
||||||
signWaitCount -= 1
|
y_start = (atTop) ? -msgwindow.height : Graphics.height
|
||||||
if atTop
|
y_end = (atTop) ? 0 : Graphics.height - msgwindow.height
|
||||||
msgwindow.y = -msgwindow.height * signWaitCount / signWaitTime
|
msgwindow.y = lerp(y_start, y_end, appear_duration, appear_timer_start, System.uptime)
|
||||||
else
|
appear_timer_start = nil if msgwindow.y == y_end
|
||||||
msgwindow.y = Graphics.height - (msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
controls.length.times do |i|
|
controls.length.times do |i|
|
||||||
next if !controls[i]
|
next if !controls[i]
|
||||||
@@ -599,34 +595,35 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
battlepointswindow&.dispose
|
battlepointswindow&.dispose
|
||||||
battlepointswindow = pbDisplayBattlePointsWindow(msgwindow)
|
battlepointswindow = pbDisplayBattlePointsWindow(msgwindow)
|
||||||
when "wu"
|
when "wu"
|
||||||
msgwindow.y = 0
|
|
||||||
atTop = true
|
atTop = true
|
||||||
msgback.y = msgwindow.y if msgback
|
msgwindow.y = 0
|
||||||
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
||||||
msgwindow.y = -msgwindow.height * signWaitCount / signWaitTime
|
if appear_timer_start
|
||||||
|
msgwindow.y = lerp(y_start, y_end, appear_duration, appear_timer_start, System.uptime)
|
||||||
|
end
|
||||||
when "wm"
|
when "wm"
|
||||||
atTop = false
|
atTop = false
|
||||||
msgwindow.y = (Graphics.height - msgwindow.height) / 2
|
msgwindow.y = (Graphics.height - msgwindow.height) / 2
|
||||||
msgback.y = msgwindow.y if msgback
|
|
||||||
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
||||||
when "wd"
|
when "wd"
|
||||||
atTop = false
|
atTop = false
|
||||||
msgwindow.y = Graphics.height - msgwindow.height
|
msgwindow.y = Graphics.height - msgwindow.height
|
||||||
msgback.y = msgwindow.y if msgback
|
|
||||||
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
||||||
msgwindow.y = Graphics.height - (msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime)
|
if appear_timer_start
|
||||||
|
msgwindow.y = lerp(y_start, y_end, appear_duration, appear_timer_start, System.uptime)
|
||||||
|
end
|
||||||
when "ts" # Change text speed
|
when "ts" # Change text speed
|
||||||
msgwindow.textspeed = (param == "") ? -999 : param.to_i
|
msgwindow.textspeed = (param == "") ? -999 : param.to_i
|
||||||
when "." # Wait 0.25 seconds
|
when "." # Wait 0.25 seconds
|
||||||
msgwindow.waitcount += Graphics.frame_rate / 4
|
msgwindow.waitcount += 0.25
|
||||||
when "|" # Wait 1 second
|
when "|" # Wait 1 second
|
||||||
msgwindow.waitcount += Graphics.frame_rate
|
msgwindow.waitcount += 1.0
|
||||||
when "wt" # Wait X/20 seconds
|
when "wt" # Wait X/20 seconds
|
||||||
param = param.sub(/\A\s+/, "").sub(/\s+\z/, "")
|
param = param.sub(/\A\s+/, "").sub(/\s+\z/, "")
|
||||||
msgwindow.waitcount += param.to_i * Graphics.frame_rate / 20
|
msgwindow.waitcount += param.to_i / 20.0
|
||||||
when "wtnp" # Wait X/20 seconds, no pause
|
when "wtnp" # Wait X/20 seconds, no pause
|
||||||
param = param.sub(/\A\s+/, "").sub(/\s+\z/, "")
|
param = param.sub(/\A\s+/, "").sub(/\s+\z/, "")
|
||||||
msgwindow.waitcount = param.to_i * Graphics.frame_rate / 20
|
msgwindow.waitcount = param.to_i / 20.0
|
||||||
autoresume = true
|
autoresume = true
|
||||||
when "^" # Wait, no pause
|
when "^" # Wait, no pause
|
||||||
autoresume = true
|
autoresume = true
|
||||||
@@ -649,7 +646,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
if msgwindow.busy?
|
if msgwindow.busy?
|
||||||
pbPlayDecisionSE if msgwindow.pausing?
|
pbPlayDecisionSE if msgwindow.pausing?
|
||||||
msgwindow.resume
|
msgwindow.resume
|
||||||
elsif signWaitCount == 0
|
elsif !appear_timer_start
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -665,7 +662,6 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
$game_map.need_refresh = true if $game_map
|
$game_map.need_refresh = true if $game_map
|
||||||
end
|
end
|
||||||
ret = commandProc.call(msgwindow) if commandProc
|
ret = commandProc.call(msgwindow) if commandProc
|
||||||
msgback&.dispose
|
|
||||||
goldwindow&.dispose
|
goldwindow&.dispose
|
||||||
coinwindow&.dispose
|
coinwindow&.dispose
|
||||||
battlepointswindow&.dispose
|
battlepointswindow&.dispose
|
||||||
@@ -673,16 +669,17 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
|||||||
if haveSpecialClose
|
if haveSpecialClose
|
||||||
pbSEPlay(pbStringToAudioFile(specialCloseSE))
|
pbSEPlay(pbStringToAudioFile(specialCloseSE))
|
||||||
atTop = (msgwindow.y == 0)
|
atTop = (msgwindow.y == 0)
|
||||||
(0..signWaitTime).each do |i|
|
y_start = (atTop) ? 0 : Graphics.height - msgwindow.height
|
||||||
if atTop
|
y_end = (atTop) ? -msgwindow.height : Graphics.height
|
||||||
msgwindow.y = -msgwindow.height * i / signWaitTime
|
disappear_duration = 0.5 # In seconds
|
||||||
else
|
disappear_timer_start = System.uptime
|
||||||
msgwindow.y = Graphics.height - (msgwindow.height * (signWaitTime - i) / signWaitTime)
|
loop do
|
||||||
end
|
msgwindow.y = lerp(y_start, y_end, disappear_duration, disappear_timer_start, System.uptime)
|
||||||
Graphics.update
|
Graphics.update
|
||||||
Input.update
|
Input.update
|
||||||
pbUpdateSceneMap
|
pbUpdateSceneMap
|
||||||
msgwindow.update
|
msgwindow.update
|
||||||
|
break if msgwindow.y == y_end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
|
|||||||
@@ -68,17 +68,22 @@ end
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbHiddenMoveAnimation(pokemon)
|
def pbHiddenMoveAnimation(pokemon)
|
||||||
return false if !pokemon
|
return false if !pokemon
|
||||||
viewport = Viewport.new(0, 0, 0, 0)
|
viewport = Viewport.new(0, 0, Graphics.width, 0)
|
||||||
viewport.z = 99999
|
viewport.z = 99999
|
||||||
|
# Set up sprites
|
||||||
bg = Sprite.new(viewport)
|
bg = Sprite.new(viewport)
|
||||||
bg.bitmap = RPG::Cache.ui("Field move/bg")
|
bg.bitmap = RPG::Cache.ui("Field move/bg")
|
||||||
sprite = PokemonSprite.new(viewport)
|
sprite = PokemonSprite.new(viewport)
|
||||||
sprite.setOffset(PictureOrigin::CENTER)
|
sprite.setOffset(PictureOrigin::CENTER)
|
||||||
sprite.setPokemonBitmap(pokemon)
|
sprite.setPokemonBitmap(pokemon)
|
||||||
|
sprite.x = Graphics.width + (sprite.bitmap.width / 2)
|
||||||
|
sprite.y = bg.bitmap.height / 2
|
||||||
sprite.z = 1
|
sprite.z = 1
|
||||||
sprite.visible = false
|
sprite.visible = false
|
||||||
strobebitmap = AnimatedBitmap.new("Graphics/UI/Field move/strobes")
|
strobebitmap = AnimatedBitmap.new("Graphics/UI/Field move/strobes")
|
||||||
strobes = []
|
strobes = []
|
||||||
|
strobes_start_x = []
|
||||||
|
strobes_timers = []
|
||||||
15.times do |i|
|
15.times do |i|
|
||||||
strobe = BitmapSprite.new(52, 16, viewport)
|
strobe = BitmapSprite.new(52, 16, viewport)
|
||||||
strobe.bitmap.blt(0, 0, strobebitmap.bitmap, Rect.new(0, (i % 2) * 16, 52, 16))
|
strobe.bitmap.blt(0, 0, strobebitmap.bitmap, Rect.new(0, (i % 2) * 16, 52, 16))
|
||||||
@@ -87,74 +92,54 @@ def pbHiddenMoveAnimation(pokemon)
|
|||||||
strobes.push(strobe)
|
strobes.push(strobe)
|
||||||
end
|
end
|
||||||
strobebitmap.dispose
|
strobebitmap.dispose
|
||||||
interp = RectInterpolator.new(
|
# Do the animation
|
||||||
Rect.new(0, Graphics.height / 2, Graphics.width, 0),
|
|
||||||
Rect.new(0, (Graphics.height - bg.bitmap.height) / 2, Graphics.width, bg.bitmap.height),
|
|
||||||
Graphics.frame_rate / 4
|
|
||||||
)
|
|
||||||
ptinterp = nil
|
|
||||||
phase = 1
|
phase = 1
|
||||||
frames = 0
|
timer_start = System.uptime
|
||||||
strobeSpeed = 64 * 20 / Graphics.frame_rate
|
|
||||||
loop do
|
loop do
|
||||||
Graphics.update
|
Graphics.update
|
||||||
Input.update
|
Input.update
|
||||||
sprite.update
|
sprite.update
|
||||||
case phase
|
case phase
|
||||||
when 1 # Expand viewport height from zero to full
|
when 1 # Expand viewport height from zero to full
|
||||||
interp.update
|
viewport.rect.y = lerp(Graphics.height / 2, (Graphics.height - bg.bitmap.height) / 2,
|
||||||
interp.set(viewport.rect)
|
0.25, timer_start, System.uptime)
|
||||||
|
viewport.rect.height = Graphics.height - viewport.rect.y * 2
|
||||||
bg.oy = (bg.bitmap.height - viewport.rect.height) / 2
|
bg.oy = (bg.bitmap.height - viewport.rect.height) / 2
|
||||||
if interp.done?
|
if viewport.rect.y == (Graphics.height - bg.bitmap.height) / 2
|
||||||
phase = 2
|
phase = 2
|
||||||
ptinterp = PointInterpolator.new(
|
sprite.visible = true
|
||||||
Graphics.width + (sprite.bitmap.width / 2), bg.bitmap.height / 2,
|
timer_start = System.uptime
|
||||||
Graphics.width / 2, bg.bitmap.height / 2,
|
|
||||||
Graphics.frame_rate * 4 / 10
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
when 2 # Slide Pokémon sprite in from right to centre
|
when 2 # Slide Pokémon sprite in from right to centre
|
||||||
ptinterp.update
|
sprite.x = lerp(Graphics.width + (sprite.bitmap.width / 2), Graphics.width / 2,
|
||||||
sprite.x = ptinterp.x
|
0.4, timer_start, System.uptime)
|
||||||
sprite.y = ptinterp.y
|
if sprite.x == Graphics.width / 2
|
||||||
sprite.visible = true
|
|
||||||
if ptinterp.done?
|
|
||||||
phase = 3
|
phase = 3
|
||||||
pokemon.play_cry
|
pokemon.play_cry
|
||||||
frames = 0
|
timer_start = System.uptime
|
||||||
end
|
end
|
||||||
when 3 # Wait
|
when 3 # Wait
|
||||||
frames += 1
|
if System.uptime - timer_start >= 0.75
|
||||||
if frames > Graphics.frame_rate * 3 / 4
|
|
||||||
phase = 4
|
phase = 4
|
||||||
ptinterp = PointInterpolator.new(
|
timer_start = System.uptime
|
||||||
Graphics.width / 2, bg.bitmap.height / 2,
|
|
||||||
-(sprite.bitmap.width / 2), bg.bitmap.height / 2,
|
|
||||||
Graphics.frame_rate * 4 / 10
|
|
||||||
)
|
|
||||||
frames = 0
|
|
||||||
end
|
end
|
||||||
when 4 # Slide Pokémon sprite off from centre to left
|
when 4 # Slide Pokémon sprite off from centre to left
|
||||||
ptinterp.update
|
sprite.x = lerp(Graphics.width / 2, -(sprite.bitmap.width / 2),
|
||||||
sprite.x = ptinterp.x
|
0.4, timer_start, System.uptime)
|
||||||
sprite.y = ptinterp.y
|
if sprite.x == -(sprite.bitmap.width / 2)
|
||||||
if ptinterp.done?
|
|
||||||
phase = 5
|
phase = 5
|
||||||
sprite.visible = false
|
sprite.visible = false
|
||||||
interp = RectInterpolator.new(
|
timer_start = System.uptime
|
||||||
Rect.new(0, (Graphics.height - bg.bitmap.height) / 2, Graphics.width, bg.bitmap.height),
|
|
||||||
Rect.new(0, Graphics.height / 2, Graphics.width, 0),
|
|
||||||
Graphics.frame_rate / 4
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
when 5 # Shrink viewport height from full to zero
|
when 5 # Shrink viewport height from full to zero
|
||||||
interp.update
|
viewport.rect.y = lerp((Graphics.height - bg.bitmap.height) / 2, Graphics.height / 2,
|
||||||
interp.set(viewport.rect)
|
0.25, timer_start, System.uptime)
|
||||||
|
viewport.rect.height = Graphics.height - viewport.rect.y * 2
|
||||||
bg.oy = (bg.bitmap.height - viewport.rect.height) / 2
|
bg.oy = (bg.bitmap.height - viewport.rect.height) / 2
|
||||||
phase = 6 if interp.done?
|
phase = 6 if viewport.rect.y == Graphics.height / 2
|
||||||
end
|
end
|
||||||
# Constantly stream the strobes across the screen
|
# Constantly stream the strobes across the screen
|
||||||
strobes.each do |strobe|
|
strobes.each_with_index do |strobe, i|
|
||||||
strobe.ox = strobe.viewport.rect.x
|
strobe.ox = strobe.viewport.rect.x
|
||||||
strobe.oy = strobe.viewport.rect.y
|
strobe.oy = strobe.viewport.rect.y
|
||||||
if !strobe.visible # Initial placement of strobes
|
if !strobe.visible # Initial placement of strobes
|
||||||
@@ -162,12 +147,16 @@ def pbHiddenMoveAnimation(pokemon)
|
|||||||
strobe.y = randomY + ((Graphics.height - bg.bitmap.height) / 2)
|
strobe.y = randomY + ((Graphics.height - bg.bitmap.height) / 2)
|
||||||
strobe.x = rand(Graphics.width)
|
strobe.x = rand(Graphics.width)
|
||||||
strobe.visible = true
|
strobe.visible = true
|
||||||
|
strobes_start_x[i] = strobe.x
|
||||||
|
strobes_timers[i] = System.uptime
|
||||||
elsif strobe.x < Graphics.width # Move strobe right
|
elsif strobe.x < Graphics.width # Move strobe right
|
||||||
strobe.x += strobeSpeed
|
strobe.x = strobes_start_x[i] + lerp(0, Graphics.width * 2, 0.8, strobes_timers[i], System.uptime)
|
||||||
else # Strobe is off the screen, reposition it to the left of the screen
|
else # Strobe is off the screen, reposition it to the left of the screen
|
||||||
randomY = 16 * (1 + rand((bg.bitmap.height / 16) - 2))
|
randomY = 16 * (1 + rand((bg.bitmap.height / 16) - 2))
|
||||||
strobe.y = randomY + ((Graphics.height - bg.bitmap.height) / 2)
|
strobe.y = randomY + ((Graphics.height - bg.bitmap.height) / 2)
|
||||||
strobe.x = -strobe.bitmap.width - rand(Graphics.width / 4)
|
strobe.x = -strobe.bitmap.width - rand(Graphics.width / 4)
|
||||||
|
strobes_start_x[i] = strobe.x
|
||||||
|
strobes_timers[i] = System.uptime
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
pbUpdateSceneMap
|
pbUpdateSceneMap
|
||||||
|
|||||||
@@ -1,483 +1,22 @@
|
|||||||
#===============================================================================
|
|
||||||
# Evolution animation metafiles and related methods
|
|
||||||
#===============================================================================
|
|
||||||
class SpriteMetafile
|
|
||||||
VIEWPORT = 0
|
|
||||||
TONE = 1
|
|
||||||
SRC_RECT = 2
|
|
||||||
VISIBLE = 3
|
|
||||||
X = 4
|
|
||||||
Y = 5
|
|
||||||
Z = 6
|
|
||||||
OX = 7
|
|
||||||
OY = 8
|
|
||||||
ZOOM_X = 9
|
|
||||||
ZOOM_Y = 10
|
|
||||||
ANGLE = 11
|
|
||||||
MIRROR = 12
|
|
||||||
BUSH_DEPTH = 13
|
|
||||||
OPACITY = 14
|
|
||||||
BLEND_TYPE = 15
|
|
||||||
COLOR = 16
|
|
||||||
FLASHCOLOR = 17
|
|
||||||
FLASHDURATION = 18
|
|
||||||
BITMAP = 19
|
|
||||||
|
|
||||||
def initialize(viewport = nil)
|
|
||||||
@metafile = []
|
|
||||||
@values = [
|
|
||||||
viewport,
|
|
||||||
Tone.new(0, 0, 0, 0), Rect.new(0, 0, 0, 0),
|
|
||||||
true,
|
|
||||||
0, 0, 0, 0, 0, 100, 100,
|
|
||||||
0, false, 0, 255, 0,
|
|
||||||
Color.new(0, 0, 0, 0), Color.new(0, 0, 0, 0),
|
|
||||||
0
|
|
||||||
]
|
|
||||||
end
|
|
||||||
|
|
||||||
def dispose; end
|
|
||||||
|
|
||||||
def disposed?
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
def [](i)
|
|
||||||
return @metafile[i]
|
|
||||||
end
|
|
||||||
|
|
||||||
def length
|
|
||||||
return @metafile.length
|
|
||||||
end
|
|
||||||
|
|
||||||
def flash(color, duration)
|
|
||||||
if duration > 0
|
|
||||||
@values[FLASHCOLOR] = color.clone
|
|
||||||
@values[FLASHDURATION] = duration
|
|
||||||
@metafile.push([FLASHCOLOR, color])
|
|
||||||
@metafile.push([FLASHDURATION, duration])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def x
|
|
||||||
return @values[X]
|
|
||||||
end
|
|
||||||
|
|
||||||
def x=(value)
|
|
||||||
@values[X] = value
|
|
||||||
@metafile.push([X, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def y
|
|
||||||
return @values[Y]
|
|
||||||
end
|
|
||||||
|
|
||||||
def y=(value)
|
|
||||||
@values[Y] = value
|
|
||||||
@metafile.push([Y, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def bitmap
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def bitmap=(value)
|
|
||||||
if value && !value.disposed?
|
|
||||||
@values[SRC_RECT].set(0, 0, value.width, value.height)
|
|
||||||
@metafile.push([SRC_RECT, @values[SRC_RECT].clone])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def src_rect
|
|
||||||
return @values[SRC_RECT]
|
|
||||||
end
|
|
||||||
|
|
||||||
def src_rect=(value)
|
|
||||||
@values[SRC_RECT] = value
|
|
||||||
@metafile.push([SRC_RECT, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def visible
|
|
||||||
return @values[VISIBLE]
|
|
||||||
end
|
|
||||||
|
|
||||||
def visible=(value)
|
|
||||||
@values[VISIBLE] = value
|
|
||||||
@metafile.push([VISIBLE, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def z
|
|
||||||
return @values[Z]
|
|
||||||
end
|
|
||||||
|
|
||||||
def z=(value)
|
|
||||||
@values[Z] = value
|
|
||||||
@metafile.push([Z, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def ox
|
|
||||||
return @values[OX]
|
|
||||||
end
|
|
||||||
|
|
||||||
def ox=(value)
|
|
||||||
@values[OX] = value
|
|
||||||
@metafile.push([OX, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def oy
|
|
||||||
return @values[OY]
|
|
||||||
end
|
|
||||||
|
|
||||||
def oy=(value)
|
|
||||||
@values[OY] = value
|
|
||||||
@metafile.push([OY, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def zoom_x
|
|
||||||
return @values[ZOOM_X]
|
|
||||||
end
|
|
||||||
|
|
||||||
def zoom_x=(value)
|
|
||||||
@values[ZOOM_X] = value
|
|
||||||
@metafile.push([ZOOM_X, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def zoom_y
|
|
||||||
return @values[ZOOM_Y]
|
|
||||||
end
|
|
||||||
|
|
||||||
def zoom_y=(value)
|
|
||||||
@values[ZOOM_Y] = value
|
|
||||||
@metafile.push([ZOOM_Y, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def zoom=(value)
|
|
||||||
@values[ZOOM_X] = value
|
|
||||||
@metafile.push([ZOOM_X, value])
|
|
||||||
@values[ZOOM_Y] = value
|
|
||||||
@metafile.push([ZOOM_Y, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def angle
|
|
||||||
return @values[ANGLE]
|
|
||||||
end
|
|
||||||
|
|
||||||
def angle=(value)
|
|
||||||
@values[ANGLE] = value
|
|
||||||
@metafile.push([ANGLE, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def mirror
|
|
||||||
return @values[MIRROR]
|
|
||||||
end
|
|
||||||
|
|
||||||
def mirror=(value)
|
|
||||||
@values[MIRROR] = value
|
|
||||||
@metafile.push([MIRROR, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def bush_depth
|
|
||||||
return @values[BUSH_DEPTH]
|
|
||||||
end
|
|
||||||
|
|
||||||
def bush_depth=(value)
|
|
||||||
@values[BUSH_DEPTH] = value
|
|
||||||
@metafile.push([BUSH_DEPTH, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def opacity
|
|
||||||
return @values[OPACITY]
|
|
||||||
end
|
|
||||||
|
|
||||||
def opacity=(value)
|
|
||||||
@values[OPACITY] = value
|
|
||||||
@metafile.push([OPACITY, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def blend_type
|
|
||||||
return @values[BLEND_TYPE]
|
|
||||||
end
|
|
||||||
|
|
||||||
def blend_type=(value)
|
|
||||||
@values[BLEND_TYPE] = value
|
|
||||||
@metafile.push([BLEND_TYPE, value])
|
|
||||||
end
|
|
||||||
|
|
||||||
def color
|
|
||||||
return @values[COLOR]
|
|
||||||
end
|
|
||||||
|
|
||||||
def color=(value)
|
|
||||||
@values[COLOR] = value.clone
|
|
||||||
@metafile.push([COLOR, @values[COLOR]])
|
|
||||||
end
|
|
||||||
|
|
||||||
def tone
|
|
||||||
return @values[TONE]
|
|
||||||
end
|
|
||||||
|
|
||||||
def tone=(value)
|
|
||||||
@values[TONE] = value.clone
|
|
||||||
@metafile.push([TONE, @values[TONE]])
|
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
|
||||||
@metafile.push([-1, nil])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
#
|
|
||||||
#===============================================================================
|
|
||||||
class SpriteMetafilePlayer
|
|
||||||
def initialize(metafile, sprite = nil)
|
|
||||||
@metafile = metafile
|
|
||||||
@sprites = []
|
|
||||||
@playing = false
|
|
||||||
@index = 0
|
|
||||||
@sprites.push(sprite) if sprite
|
|
||||||
end
|
|
||||||
|
|
||||||
def add(sprite)
|
|
||||||
@sprites.push(sprite)
|
|
||||||
end
|
|
||||||
|
|
||||||
def playing?
|
|
||||||
return @playing
|
|
||||||
end
|
|
||||||
|
|
||||||
def play
|
|
||||||
@playing = true
|
|
||||||
@index = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
|
||||||
return if !@playing
|
|
||||||
(@index...@metafile.length).each do |j|
|
|
||||||
@index = j + 1
|
|
||||||
break if @metafile[j][0] < 0
|
|
||||||
code = @metafile[j][0]
|
|
||||||
value = @metafile[j][1]
|
|
||||||
@sprites.each do |sprite|
|
|
||||||
case code
|
|
||||||
when SpriteMetafile::X then sprite.x = value
|
|
||||||
when SpriteMetafile::Y then sprite.y = value
|
|
||||||
when SpriteMetafile::OX then sprite.ox = value
|
|
||||||
when SpriteMetafile::OY then sprite.oy = value
|
|
||||||
when SpriteMetafile::ZOOM_X then sprite.zoom_x = value
|
|
||||||
when SpriteMetafile::ZOOM_Y then sprite.zoom_y = value
|
|
||||||
when SpriteMetafile::SRC_RECT then sprite.src_rect = value
|
|
||||||
when SpriteMetafile::VISIBLE then sprite.visible = value
|
|
||||||
when SpriteMetafile::Z then sprite.z = value # prevent crashes
|
|
||||||
when SpriteMetafile::ANGLE then sprite.angle = (value == 180) ? 179.9 : value
|
|
||||||
when SpriteMetafile::MIRROR then sprite.mirror = value
|
|
||||||
when SpriteMetafile::BUSH_DEPTH then sprite.bush_depth = value
|
|
||||||
when SpriteMetafile::OPACITY then sprite.opacity = value
|
|
||||||
when SpriteMetafile::BLEND_TYPE then sprite.blend_type = value
|
|
||||||
when SpriteMetafile::COLOR then sprite.color = value
|
|
||||||
when SpriteMetafile::TONE then sprite.tone = value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@playing = false if @index == @metafile.length
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
#
|
|
||||||
#===============================================================================
|
|
||||||
def pbSaveSpriteState(sprite)
|
|
||||||
state = []
|
|
||||||
return state if !sprite || sprite.disposed?
|
|
||||||
state[SpriteMetafile::BITMAP] = sprite.x
|
|
||||||
state[SpriteMetafile::X] = sprite.x
|
|
||||||
state[SpriteMetafile::Y] = sprite.y
|
|
||||||
state[SpriteMetafile::SRC_RECT] = sprite.src_rect.clone
|
|
||||||
state[SpriteMetafile::VISIBLE] = sprite.visible
|
|
||||||
state[SpriteMetafile::Z] = sprite.z
|
|
||||||
state[SpriteMetafile::OX] = sprite.ox
|
|
||||||
state[SpriteMetafile::OY] = sprite.oy
|
|
||||||
state[SpriteMetafile::ZOOM_X] = sprite.zoom_x
|
|
||||||
state[SpriteMetafile::ZOOM_Y] = sprite.zoom_y
|
|
||||||
state[SpriteMetafile::ANGLE] = sprite.angle
|
|
||||||
state[SpriteMetafile::MIRROR] = sprite.mirror
|
|
||||||
state[SpriteMetafile::BUSH_DEPTH] = sprite.bush_depth
|
|
||||||
state[SpriteMetafile::OPACITY] = sprite.opacity
|
|
||||||
state[SpriteMetafile::BLEND_TYPE] = sprite.blend_type
|
|
||||||
state[SpriteMetafile::COLOR] = sprite.color.clone
|
|
||||||
state[SpriteMetafile::TONE] = sprite.tone.clone
|
|
||||||
return state
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbRestoreSpriteState(sprite, state)
|
|
||||||
return if !state || !sprite || sprite.disposed?
|
|
||||||
sprite.x = state[SpriteMetafile::X]
|
|
||||||
sprite.y = state[SpriteMetafile::Y]
|
|
||||||
sprite.src_rect = state[SpriteMetafile::SRC_RECT]
|
|
||||||
sprite.visible = state[SpriteMetafile::VISIBLE]
|
|
||||||
sprite.z = state[SpriteMetafile::Z]
|
|
||||||
sprite.ox = state[SpriteMetafile::OX]
|
|
||||||
sprite.oy = state[SpriteMetafile::OY]
|
|
||||||
sprite.zoom_x = state[SpriteMetafile::ZOOM_X]
|
|
||||||
sprite.zoom_y = state[SpriteMetafile::ZOOM_Y]
|
|
||||||
sprite.angle = state[SpriteMetafile::ANGLE]
|
|
||||||
sprite.mirror = state[SpriteMetafile::MIRROR]
|
|
||||||
sprite.bush_depth = state[SpriteMetafile::BUSH_DEPTH]
|
|
||||||
sprite.opacity = state[SpriteMetafile::OPACITY]
|
|
||||||
sprite.blend_type = state[SpriteMetafile::BLEND_TYPE]
|
|
||||||
sprite.color = state[SpriteMetafile::COLOR]
|
|
||||||
sprite.tone = state[SpriteMetafile::TONE]
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbSaveSpriteStateAndBitmap(sprite)
|
|
||||||
return [] if !sprite || sprite.disposed?
|
|
||||||
state = pbSaveSpriteState(sprite)
|
|
||||||
state[SpriteMetafile::BITMAP] = sprite.bitmap
|
|
||||||
return state
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbRestoreSpriteStateAndBitmap(sprite, state)
|
|
||||||
return if !state || !sprite || sprite.disposed?
|
|
||||||
sprite.bitmap = state[SpriteMetafile::BITMAP]
|
|
||||||
pbRestoreSpriteState(sprite, state)
|
|
||||||
return state
|
|
||||||
end
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Evolution screen
|
# Evolution screen
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class PokemonEvolutionScene
|
class PokemonEvolutionScene
|
||||||
private
|
def self.pbDuplicatePokemon(pkmn, new_species)
|
||||||
|
new_pkmn = pkmn.clone
|
||||||
def pbGenerateMetafiles(s1x, s1y, s2x, s2y)
|
new_pkmn.species = new_species
|
||||||
sprite = SpriteMetafile.new
|
new_pkmn.name = nil
|
||||||
sprite.ox = s1x
|
new_pkmn.markings = []
|
||||||
sprite.oy = s1y
|
new_pkmn.poke_ball = :POKEBALL
|
||||||
sprite.opacity = 255
|
new_pkmn.item = nil
|
||||||
sprite2 = SpriteMetafile.new
|
new_pkmn.clearAllRibbons
|
||||||
sprite2.ox = s2x
|
new_pkmn.calc_stats
|
||||||
sprite2.oy = s2y
|
new_pkmn.heal
|
||||||
sprite2.zoom = 0.0
|
# Add duplicate Pokémon to party
|
||||||
sprite2.opacity = 255
|
$player.party.push(new_pkmn)
|
||||||
alpha = 0
|
# See and own duplicate Pokémon
|
||||||
alphaDiff = 10 * 20 / Graphics.frame_rate
|
$player.pokedex.register(new_pkmn)
|
||||||
loop do
|
$player.pokedex.set_owned(new_species)
|
||||||
sprite.color.red = 255
|
|
||||||
sprite.color.green = 255
|
|
||||||
sprite.color.blue = 255
|
|
||||||
sprite.color.alpha = alpha
|
|
||||||
sprite.color = sprite.color
|
|
||||||
sprite2.color = sprite.color
|
|
||||||
sprite2.color.alpha = 255
|
|
||||||
sprite.update
|
|
||||||
sprite2.update
|
|
||||||
break if alpha >= 255
|
|
||||||
alpha += alphaDiff
|
|
||||||
end
|
|
||||||
totaltempo = 0
|
|
||||||
currenttempo = 25
|
|
||||||
maxtempo = 7 * Graphics.frame_rate
|
|
||||||
while totaltempo < maxtempo
|
|
||||||
currenttempo.times do |j|
|
|
||||||
if alpha < 255
|
|
||||||
sprite.color.red = 255
|
|
||||||
sprite.color.green = 255
|
|
||||||
sprite.color.blue = 255
|
|
||||||
sprite.color.alpha = alpha
|
|
||||||
sprite.color = sprite.color
|
|
||||||
alpha += 10
|
|
||||||
end
|
|
||||||
sprite.zoom = [1.1 * (currenttempo - j - 1) / currenttempo, 1.0].min
|
|
||||||
sprite2.zoom = [1.1 * (j + 1) / currenttempo, 1.0].min
|
|
||||||
sprite.update
|
|
||||||
sprite2.update
|
|
||||||
end
|
|
||||||
totaltempo += currenttempo
|
|
||||||
if totaltempo + currenttempo < maxtempo
|
|
||||||
currenttempo.times do |j|
|
|
||||||
sprite.zoom = [1.1 * (j + 1) / currenttempo, 1.0].min
|
|
||||||
sprite2.zoom = [1.1 * (currenttempo - j - 1) / currenttempo, 1.0].min
|
|
||||||
sprite.update
|
|
||||||
sprite2.update
|
|
||||||
end
|
|
||||||
end
|
|
||||||
totaltempo += currenttempo
|
|
||||||
currenttempo = [(currenttempo / 1.5).floor, 5].max
|
|
||||||
end
|
|
||||||
@metafile1 = sprite
|
|
||||||
@metafile2 = sprite2
|
|
||||||
end
|
|
||||||
|
|
||||||
public
|
|
||||||
|
|
||||||
def pbUpdate(animating = false)
|
|
||||||
if animating # Pokémon shouldn't animate during the evolution animation
|
|
||||||
@sprites["background"].update
|
|
||||||
@sprites["msgwindow"].update
|
|
||||||
else
|
|
||||||
pbUpdateSpriteHash(@sprites)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbUpdateNarrowScreen(timer_start)
|
|
||||||
return if @bgviewport.rect.y >= 80
|
|
||||||
buffer = 80
|
|
||||||
@bgviewport.rect.height = Graphics.height - lerp(0, 64 + (buffer * 2), 0.7, timer_start, System.uptime).to_i
|
|
||||||
@bgviewport.rect.y = lerp(0, buffer, 0.5, timer_start + 0.2, System.uptime).to_i
|
|
||||||
@sprites["background"].oy = @bgviewport.rect.y
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbUpdateExpandScreen(timer_start)
|
|
||||||
return if @bgviewport.rect.height >= Graphics.height
|
|
||||||
buffer = 80
|
|
||||||
@bgviewport.rect.height = Graphics.height - lerp(64 + (buffer * 2), 0, 0.7, timer_start, System.uptime).to_i
|
|
||||||
@bgviewport.rect.y = lerp(buffer, 0, 0.5, timer_start, System.uptime).to_i
|
|
||||||
@sprites["background"].oy = @bgviewport.rect.y
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbFlashInOut(canceled, oldstate, oldstate2)
|
|
||||||
timer_start = System.uptime
|
|
||||||
loop do
|
|
||||||
Graphics.update
|
|
||||||
pbUpdate(true)
|
|
||||||
pbUpdateExpandScreen(timer_start)
|
|
||||||
tone = lerp(0, 255, 0.7, timer_start, System.uptime)
|
|
||||||
@viewport.tone.set(tone, tone, tone, 0)
|
|
||||||
break if tone >= 255
|
|
||||||
end
|
|
||||||
@bgviewport.rect.y = 0
|
|
||||||
@bgviewport.rect.height = Graphics.height
|
|
||||||
@sprites["background"].oy = 0
|
|
||||||
if canceled
|
|
||||||
pbRestoreSpriteState(@sprites["rsprite1"], oldstate)
|
|
||||||
pbRestoreSpriteState(@sprites["rsprite2"], oldstate2)
|
|
||||||
@sprites["rsprite1"].zoom_x = 1.0
|
|
||||||
@sprites["rsprite1"].zoom_y = 1.0
|
|
||||||
@sprites["rsprite1"].color.alpha = 0
|
|
||||||
@sprites["rsprite1"].visible = true
|
|
||||||
@sprites["rsprite2"].visible = false
|
|
||||||
else
|
|
||||||
@sprites["rsprite1"].visible = false
|
|
||||||
@sprites["rsprite2"].visible = true
|
|
||||||
@sprites["rsprite2"].zoom_x = 1.0
|
|
||||||
@sprites["rsprite2"].zoom_y = 1.0
|
|
||||||
@sprites["rsprite2"].color.alpha = 0
|
|
||||||
end
|
|
||||||
timer_start = System.uptime
|
|
||||||
loop do
|
|
||||||
Graphics.update
|
|
||||||
pbUpdate(true)
|
|
||||||
break if System.uptime - timer_start >= 0.25
|
|
||||||
end
|
|
||||||
timer_start = System.uptime
|
|
||||||
loop do
|
|
||||||
Graphics.update
|
|
||||||
pbUpdate
|
|
||||||
pbUpdateExpandScreen(timer_start)
|
|
||||||
tone = lerp(255, 0, 0.4, timer_start, System.uptime)
|
|
||||||
@viewport.tone.set(tone, tone, tone, 0)
|
|
||||||
break if tone <= 0
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbStartScreen(pokemon, newspecies)
|
def pbStartScreen(pokemon, newspecies)
|
||||||
@@ -502,32 +41,47 @@ class PokemonEvolutionScene
|
|||||||
rsprite2.setPokemonBitmapSpecies(@pokemon, @newspecies, false)
|
rsprite2.setPokemonBitmapSpecies(@pokemon, @newspecies, false)
|
||||||
rsprite2.x = rsprite1.x
|
rsprite2.x = rsprite1.x
|
||||||
rsprite2.y = rsprite1.y
|
rsprite2.y = rsprite1.y
|
||||||
rsprite2.opacity = 0
|
rsprite2.visible = false
|
||||||
@sprites["rsprite1"] = rsprite1
|
@sprites["rsprite1"] = rsprite1
|
||||||
@sprites["rsprite2"] = rsprite2
|
@sprites["rsprite2"] = rsprite2
|
||||||
pbGenerateMetafiles(rsprite1.ox, rsprite1.oy, rsprite2.ox, rsprite2.oy)
|
|
||||||
@sprites["msgwindow"] = pbCreateMessageWindow(@msgviewport)
|
@sprites["msgwindow"] = pbCreateMessageWindow(@msgviewport)
|
||||||
|
set_up_animation
|
||||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Closes the evolution screen.
|
def set_up_animation
|
||||||
def pbEndScreen(need_fade_out = true)
|
sprite = PictureEx.new(0)
|
||||||
pbDisposeMessageWindow(@sprites["msgwindow"]) if @sprites["msgwindow"]
|
sprite.setVisible(0, true)
|
||||||
if need_fade_out
|
sprite.setColor(0, Color.new(255, 255, 255, 0))
|
||||||
pbFadeOutAndHide(@sprites) { pbUpdate }
|
sprite2 = PictureEx.new(0)
|
||||||
|
sprite2.setVisible(0, true)
|
||||||
|
sprite2.setZoom(0, 0.0)
|
||||||
|
sprite2.setColor(0, Color.new(255, 255, 255, 255))
|
||||||
|
# Make sprite turn white
|
||||||
|
sprite.moveColor(0, 25, Color.new(255, 255, 255, 255))
|
||||||
|
total_duration = 9 * 20 # 9 seconds
|
||||||
|
duration = 25 + 15
|
||||||
|
zoom_duration = 12
|
||||||
|
loop do
|
||||||
|
# Shrink prevo sprite, enlarge evo sprite
|
||||||
|
sprite.moveZoom(duration, zoom_duration, 0)
|
||||||
|
sprite2.moveZoom(duration, zoom_duration, 110)
|
||||||
|
duration += zoom_duration
|
||||||
|
# If animation has played for long enough, end it now while the evo sprite is large
|
||||||
|
break if duration >= total_duration
|
||||||
|
# Enlarge prevo sprite, shrink evo sprite
|
||||||
|
sprite.moveZoom(duration, zoom_duration, 110)
|
||||||
|
sprite2.moveZoom(duration, zoom_duration, 0)
|
||||||
|
duration += zoom_duration
|
||||||
|
# Shorten the duration of zoom changes for the next cycle
|
||||||
|
zoom_duration = [(zoom_duration / 1.2).round, 2].max
|
||||||
end
|
end
|
||||||
pbDisposeSpriteHash(@sprites)
|
@picture1 = sprite
|
||||||
@viewport.dispose
|
@picture2 = sprite2
|
||||||
@bgviewport.dispose
|
|
||||||
@msgviewport.dispose
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Opens the evolution screen
|
# Opens the evolution screen
|
||||||
def pbEvolution(cancancel = true)
|
def pbEvolution(cancancel = true)
|
||||||
metaplayer1 = SpriteMetafilePlayer.new(@metafile1, @sprites["rsprite1"])
|
|
||||||
metaplayer2 = SpriteMetafilePlayer.new(@metafile2, @sprites["rsprite2"])
|
|
||||||
metaplayer1.play
|
|
||||||
metaplayer2.play
|
|
||||||
pbBGMStop
|
pbBGMStop
|
||||||
pbMessageDisplay(@sprites["msgwindow"], "\\se[]" + _INTL("What?") + "\1") { pbUpdate }
|
pbMessageDisplay(@sprites["msgwindow"], "\\se[]" + _INTL("What?") + "\1") { pbUpdate }
|
||||||
pbPlayDecisionSE
|
pbPlayDecisionSE
|
||||||
@@ -540,16 +94,24 @@ class PokemonEvolutionScene
|
|||||||
pbUpdate
|
pbUpdate
|
||||||
break if System.uptime - timer_start >= 1
|
break if System.uptime - timer_start >= 1
|
||||||
end
|
end
|
||||||
oldstate = pbSaveSpriteState(@sprites["rsprite1"])
|
|
||||||
oldstate2 = pbSaveSpriteState(@sprites["rsprite2"])
|
|
||||||
pbMEPlay("Evolution start")
|
pbMEPlay("Evolution start")
|
||||||
pbBGMPlay("Evolution")
|
pbBGMPlay("Evolution")
|
||||||
canceled = false
|
canceled = false
|
||||||
timer_start = System.uptime
|
timer_start = System.uptime
|
||||||
loop do
|
loop do
|
||||||
pbUpdateNarrowScreen(timer_start)
|
pbUpdateNarrowScreen(timer_start)
|
||||||
metaplayer1.update
|
@picture1.update
|
||||||
metaplayer2.update
|
setPictureSprite(@sprites["rsprite1"], @picture1)
|
||||||
|
if @sprites["rsprite1"].zoom_x > 1.0
|
||||||
|
@sprites["rsprite1"].zoom_x = 1.0
|
||||||
|
@sprites["rsprite1"].zoom_y = 1.0
|
||||||
|
end
|
||||||
|
@picture2.update
|
||||||
|
setPictureSprite(@sprites["rsprite2"], @picture2)
|
||||||
|
if @sprites["rsprite2"].zoom_x > 1.0
|
||||||
|
@sprites["rsprite2"].zoom_x = 1.0
|
||||||
|
@sprites["rsprite2"].zoom_y = 1.0
|
||||||
|
end
|
||||||
Graphics.update
|
Graphics.update
|
||||||
Input.update
|
Input.update
|
||||||
pbUpdate(true)
|
pbUpdate(true)
|
||||||
@@ -559,9 +121,9 @@ class PokemonEvolutionScene
|
|||||||
canceled = true
|
canceled = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
break unless metaplayer1.playing? && metaplayer2.playing?
|
break if !@picture1.running? && !@picture2.running?
|
||||||
end
|
end
|
||||||
pbFlashInOut(canceled, oldstate, oldstate2)
|
pbFlashInOut(canceled)
|
||||||
if canceled
|
if canceled
|
||||||
$stats.evolutions_cancelled += 1
|
$stats.evolutions_cancelled += 1
|
||||||
pbMessageDisplay(@sprites["msgwindow"],
|
pbMessageDisplay(@sprites["msgwindow"],
|
||||||
@@ -571,6 +133,65 @@ class PokemonEvolutionScene
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pbUpdateNarrowScreen(timer_start)
|
||||||
|
return if @bgviewport.rect.y >= 80
|
||||||
|
buffer = 80
|
||||||
|
@bgviewport.rect.height = Graphics.height - lerp(0, 64 + (buffer * 2), 0.7, timer_start, System.uptime).to_i
|
||||||
|
@bgviewport.rect.y = lerp(0, buffer, 0.5, timer_start + 0.2, System.uptime).to_i
|
||||||
|
@sprites["background"].oy = @bgviewport.rect.y
|
||||||
|
end
|
||||||
|
|
||||||
|
def pbUpdateExpandScreen(timer_start)
|
||||||
|
return if @bgviewport.rect.height >= Graphics.height
|
||||||
|
buffer = 80
|
||||||
|
@bgviewport.rect.height = Graphics.height - lerp(64 + (buffer * 2), 0, 0.7, timer_start, System.uptime).to_i
|
||||||
|
@bgviewport.rect.y = lerp(buffer, 0, 0.5, timer_start, System.uptime).to_i
|
||||||
|
@sprites["background"].oy = @bgviewport.rect.y
|
||||||
|
end
|
||||||
|
|
||||||
|
def pbFlashInOut(canceled)
|
||||||
|
timer_start = System.uptime
|
||||||
|
loop do
|
||||||
|
Graphics.update
|
||||||
|
pbUpdate(true)
|
||||||
|
pbUpdateExpandScreen(timer_start)
|
||||||
|
tone = lerp(0, 255, 0.7, timer_start, System.uptime)
|
||||||
|
@viewport.tone.set(tone, tone, tone, 0)
|
||||||
|
break if tone >= 255
|
||||||
|
end
|
||||||
|
@bgviewport.rect.y = 0
|
||||||
|
@bgviewport.rect.height = Graphics.height
|
||||||
|
@sprites["background"].oy = 0
|
||||||
|
if canceled
|
||||||
|
@sprites["rsprite1"].visible = true
|
||||||
|
@sprites["rsprite1"].zoom_x = 1.0
|
||||||
|
@sprites["rsprite1"].zoom_y = 1.0
|
||||||
|
@sprites["rsprite1"].color.alpha = 0
|
||||||
|
@sprites["rsprite2"].visible = false
|
||||||
|
else
|
||||||
|
@sprites["rsprite1"].visible = false
|
||||||
|
@sprites["rsprite2"].visible = true
|
||||||
|
@sprites["rsprite2"].zoom_x = 1.0
|
||||||
|
@sprites["rsprite2"].zoom_y = 1.0
|
||||||
|
@sprites["rsprite2"].color.alpha = 0
|
||||||
|
end
|
||||||
|
timer_start = System.uptime
|
||||||
|
loop do
|
||||||
|
Graphics.update
|
||||||
|
pbUpdate(true)
|
||||||
|
break if System.uptime - timer_start >= 0.25
|
||||||
|
end
|
||||||
|
timer_start = System.uptime
|
||||||
|
loop do
|
||||||
|
Graphics.update
|
||||||
|
pbUpdate
|
||||||
|
pbUpdateExpandScreen(timer_start)
|
||||||
|
tone = lerp(255, 0, 0.4, timer_start, System.uptime)
|
||||||
|
@viewport.tone.set(tone, tone, tone, 0)
|
||||||
|
break if tone <= 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def pbEvolutionSuccess
|
def pbEvolutionSuccess
|
||||||
$stats.evolution_count += 1
|
$stats.evolution_count += 1
|
||||||
# Play cry of evolved species
|
# Play cry of evolved species
|
||||||
@@ -631,20 +252,24 @@ class PokemonEvolutionScene
|
|||||||
@pokemon.action_after_evolution(@newspecies)
|
@pokemon.action_after_evolution(@newspecies)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.pbDuplicatePokemon(pkmn, new_species)
|
def pbUpdate(animating = false)
|
||||||
new_pkmn = pkmn.clone
|
if animating # Pokémon shouldn't animate during the evolution animation
|
||||||
new_pkmn.species = new_species
|
@sprites["background"].update
|
||||||
new_pkmn.name = nil
|
@sprites["msgwindow"].update
|
||||||
new_pkmn.markings = []
|
else
|
||||||
new_pkmn.poke_ball = :POKEBALL
|
pbUpdateSpriteHash(@sprites)
|
||||||
new_pkmn.item = nil
|
end
|
||||||
new_pkmn.clearAllRibbons
|
end
|
||||||
new_pkmn.calc_stats
|
|
||||||
new_pkmn.heal
|
# Closes the evolution screen.
|
||||||
# Add duplicate Pokémon to party
|
def pbEndScreen(need_fade_out = true)
|
||||||
$player.party.push(new_pkmn)
|
pbDisposeMessageWindow(@sprites["msgwindow"]) if @sprites["msgwindow"]
|
||||||
# See and own duplicate Pokémon
|
if need_fade_out
|
||||||
$player.pokedex.register(new_pkmn)
|
pbFadeOutAndHide(@sprites) { pbUpdate }
|
||||||
$player.pokedex.set_owned(new_species)
|
end
|
||||||
|
pbDisposeSpriteHash(@sprites)
|
||||||
|
@viewport.dispose
|
||||||
|
@bgviewport.dispose
|
||||||
|
@msgviewport.dispose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,30 +17,31 @@
|
|||||||
class HallOfFame_Scene
|
class HallOfFame_Scene
|
||||||
# When true, all pokémon will be in one line
|
# When true, all pokémon will be in one line
|
||||||
# When false, all pokémon will be in two lines
|
# When false, all pokémon will be in two lines
|
||||||
SINGLEROW = false
|
SINGLE_ROW_OF_POKEMON = false
|
||||||
# Make the pokémon movement ON in hall entry
|
# Make the pokémon movement ON in hall entry
|
||||||
ANIMATION = true
|
ANIMATION = true
|
||||||
# Speed in pokémon movement in hall entry. Don't use less than 2!
|
# Speed in pokémon movement in hall entry. Don't use less than 2!
|
||||||
ANIMATIONSPEED = 32
|
ANIMATIONSPEED = 32
|
||||||
# Entry wait time (in 1/20 seconds) between showing each Pokémon (and trainer)
|
# Entry wait time (in seconds) between showing each Pokémon (and trainer).
|
||||||
ENTRYWAITTIME = 64
|
# Waits for twice this tme when showing "Welcome to the Hall of Fame!".
|
||||||
|
ENTRY_WAIT_TIME = 3.0
|
||||||
# Maximum number limit of simultaneous hall entries saved.
|
# Maximum number limit of simultaneous hall entries saved.
|
||||||
# 0 = Doesn't save any hall. -1 = no limit
|
# 0 = Doesn't save any hall. -1 = no limit
|
||||||
# Prefer to use larger numbers (like 500 and 1000) than don't put a limit
|
# Prefer to use larger numbers (like 500 and 1000) than don't put a limit
|
||||||
# If a player exceed this limit, the first one will be removed
|
# If a player exceed this limit, the first one will be removed
|
||||||
HALLLIMIT = 50
|
HALL_ENTRIES_LIMIT = 50
|
||||||
# The entry music name. Put "" to doesn't play anything
|
# The entry music name. Put "" to doesn't play anything
|
||||||
ENTRYMUSIC = "Hall of Fame"
|
HALL_OF_FAME_BGM = "Hall of Fame"
|
||||||
# Allow eggs to be show and saved in hall
|
# Allow eggs to be show and saved in hall
|
||||||
ALLOWEGGS = true
|
ALLOW_EGGS = true
|
||||||
# Remove the hallbars when the trainer sprite appears
|
# Remove the hallbars when the trainer sprite appears
|
||||||
REMOVEBARS = true
|
REMOVE_BARS_WHEN_SHOWING_TRAINER = true
|
||||||
# The final fade speed on entry
|
# The final fade speed on entry
|
||||||
FINALFADESPEED = 16
|
FINAL_FADE_DURATION = 1.0
|
||||||
# Sprites opacity value when them aren't selected
|
# Sprite's opacity value when it isn't selected
|
||||||
OPACITY = 64
|
OPACITY = 64
|
||||||
BASECOLOR = Color.new(248, 248, 248)
|
TEXT_BASE_COLOR = Color.new(248, 248, 248)
|
||||||
SHADOWCOLOR = Color.new(0, 0, 0)
|
TEXT_SHADOW_COLOR = Color.new(0, 0, 0)
|
||||||
|
|
||||||
# Placement for pokemon icons
|
# Placement for pokemon icons
|
||||||
def pbStartScene
|
def pbStartScene
|
||||||
@@ -64,8 +65,8 @@ class HallOfFame_Scene
|
|||||||
|
|
||||||
def pbStartSceneEntry
|
def pbStartSceneEntry
|
||||||
pbStartScene
|
pbStartScene
|
||||||
@useMusic = (ENTRYMUSIC && ENTRYMUSIC != "")
|
@useMusic = (HALL_OF_FAME_BGM && HALL_OF_FAME_BGM != "")
|
||||||
pbBGMPlay(ENTRYMUSIC) if @useMusic
|
pbBGMPlay(HALL_OF_FAME_BGM) if @useMusic
|
||||||
saveHallEntry
|
saveHallEntry
|
||||||
@xmovement = []
|
@xmovement = []
|
||||||
@ymovement = []
|
@ymovement = []
|
||||||
@@ -90,22 +91,15 @@ class HallOfFame_Scene
|
|||||||
@viewport.dispose
|
@viewport.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def slowFadeOut(sprites, exponent) # 2 exponent
|
def slowFadeOut(duration)
|
||||||
# To handle values above 8
|
timer_start = System.uptime
|
||||||
extraWaitExponent = exponent - 9
|
loop do
|
||||||
exponent = 8 if exponent > 8
|
alpha = lerp(255, 0, duration, timer_start, System.uptime)
|
||||||
max = 2**exponent
|
pbSetSpritesToColor(@sprites, Color.new(0, 0, 0, alpha))
|
||||||
speed = (2**8) / max
|
|
||||||
(0..max).each do |j|
|
|
||||||
if extraWaitExponent > -1
|
|
||||||
(2**extraWaitExponent).times do
|
|
||||||
Graphics.update
|
Graphics.update
|
||||||
Input.update
|
Input.update
|
||||||
pbUpdate
|
pbUpdate
|
||||||
end
|
break if alpha == 0
|
||||||
end
|
|
||||||
pbSetSpritesToColor(sprites, Color.new(0, 0, 0, j * speed))
|
|
||||||
block_given? ? yield : pbUpdateSpriteHash(sprites)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -125,20 +119,21 @@ class HallOfFame_Scene
|
|||||||
def saveHallEntry
|
def saveHallEntry
|
||||||
$player.party.each do |pkmn|
|
$player.party.each do |pkmn|
|
||||||
# Clones every pokémon object
|
# Clones every pokémon object
|
||||||
@hallEntry.push(pkmn.clone) if !pkmn.egg? || ALLOWEGGS
|
@hallEntry.push(pkmn.clone) if !pkmn.egg? || ALLOW_EGGS
|
||||||
end
|
end
|
||||||
# Update the global variables
|
# Update the global variables
|
||||||
$PokemonGlobal.hallOfFame.push(@hallEntry)
|
$PokemonGlobal.hallOfFame.push(@hallEntry)
|
||||||
$PokemonGlobal.hallOfFameLastNumber += 1
|
$PokemonGlobal.hallOfFameLastNumber += 1
|
||||||
$PokemonGlobal.hallOfFame.delete_at(0) if HALLLIMIT > -1 &&
|
if HALL_ENTRIES_LIMIT >= 0 && $PokemonGlobal.hallOfFame.size > HALL_ENTRIES_LIMIT
|
||||||
$PokemonGlobal.hallOfFame.size > HALLLIMIT
|
$PokemonGlobal.hallOfFame.delete_at(0)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return the x/y point position in screen for battler index number
|
# Return the x/y point position in screen for battler index number
|
||||||
# Don't use odd numbers!
|
# Don't use odd numbers!
|
||||||
def xpointformula(battlernumber)
|
def xpointformula(battlernumber)
|
||||||
ret = 0
|
ret = 0
|
||||||
if SINGLEROW
|
if SINGLE_ROW_OF_POKEMON
|
||||||
ret = ((60 * (battlernumber / 2)) + 48) * (xpositionformula(battlernumber) - 1)
|
ret = ((60 * (battlernumber / 2)) + 48) * (xpositionformula(battlernumber) - 1)
|
||||||
ret += (Graphics.width / 2) - 56
|
ret += (Graphics.width / 2) - 56
|
||||||
else
|
else
|
||||||
@@ -149,7 +144,7 @@ class HallOfFame_Scene
|
|||||||
|
|
||||||
def ypointformula(battlernumber)
|
def ypointformula(battlernumber)
|
||||||
ret = 0
|
ret = 0
|
||||||
if SINGLEROW
|
if SINGLE_ROW_OF_POKEMON
|
||||||
ret = 96 - (8 * (battlernumber / 2))
|
ret = 96 - (8 * (battlernumber / 2))
|
||||||
else
|
else
|
||||||
ret = 32 + (128 * ypositionformula(battlernumber) / 2)
|
ret = 32 + (128 * ypositionformula(battlernumber) / 2)
|
||||||
@@ -160,7 +155,7 @@ class HallOfFame_Scene
|
|||||||
# Returns 0, 1 or 2 as the x/y column value
|
# Returns 0, 1 or 2 as the x/y column value
|
||||||
def xpositionformula(battlernumber)
|
def xpositionformula(battlernumber)
|
||||||
ret = 0
|
ret = 0
|
||||||
if SINGLEROW
|
if SINGLE_ROW_OF_POKEMON
|
||||||
ret = (battlernumber % 2) * 2
|
ret = (battlernumber % 2) * 2
|
||||||
else
|
else
|
||||||
ret = (battlernumber / 3).even? ? (19 - battlernumber) % 3 : (19 + battlernumber) % 3
|
ret = (battlernumber / 3).even? ? (19 - battlernumber) % 3 : (19 + battlernumber) % 3
|
||||||
@@ -170,7 +165,7 @@ class HallOfFame_Scene
|
|||||||
|
|
||||||
def ypositionformula(battlernumber)
|
def ypositionformula(battlernumber)
|
||||||
ret = 0
|
ret = 0
|
||||||
if SINGLEROW
|
if SINGLE_ROW_OF_POKEMON
|
||||||
ret = 1
|
ret = 1
|
||||||
else
|
else
|
||||||
ret = ((battlernumber / 3) % 2) * 2
|
ret = ((battlernumber / 3) % 2) * 2
|
||||||
@@ -219,7 +214,7 @@ class HallOfFame_Scene
|
|||||||
@sprites["pokemon#{i}"].x += (128 - @sprites["pokemon#{i}"].bitmap.width) / 2
|
@sprites["pokemon#{i}"].x += (128 - @sprites["pokemon#{i}"].bitmap.width) / 2
|
||||||
@sprites["pokemon#{i}"].y += (128 - @sprites["pokemon#{i}"].bitmap.height) / 2
|
@sprites["pokemon#{i}"].y += (128 - @sprites["pokemon#{i}"].bitmap.height) / 2
|
||||||
end
|
end
|
||||||
@sprites["pokemon#{i}"].z = 7 - i if SINGLEROW
|
@sprites["pokemon#{i}"].z = 7 - i if SINGLE_ROW_OF_POKEMON
|
||||||
next if !hide
|
next if !hide
|
||||||
# Animation distance calculation
|
# Animation distance calculation
|
||||||
horizontal = 1 - xpositionformula(i)
|
horizontal = 1 - xpositionformula(i)
|
||||||
@@ -244,7 +239,7 @@ class HallOfFame_Scene
|
|||||||
def createTrainerBattler
|
def createTrainerBattler
|
||||||
@sprites["trainer"] = IconSprite.new(@viewport)
|
@sprites["trainer"] = IconSprite.new(@viewport)
|
||||||
@sprites["trainer"].setBitmap(GameData::TrainerType.front_sprite_filename($player.trainer_type))
|
@sprites["trainer"].setBitmap(GameData::TrainerType.front_sprite_filename($player.trainer_type))
|
||||||
if SINGLEROW
|
if SINGLE_ROW_OF_POKEMON
|
||||||
@sprites["trainer"].x = Graphics.width / 2
|
@sprites["trainer"].x = Graphics.width / 2
|
||||||
@sprites["trainer"].y = 178
|
@sprites["trainer"].y = 178
|
||||||
else
|
else
|
||||||
@@ -254,22 +249,24 @@ class HallOfFame_Scene
|
|||||||
@sprites["trainer"].z = 9
|
@sprites["trainer"].z = 9
|
||||||
@sprites["trainer"].ox = @sprites["trainer"].bitmap.width / 2
|
@sprites["trainer"].ox = @sprites["trainer"].bitmap.width / 2
|
||||||
@sprites["trainer"].oy = @sprites["trainer"].bitmap.height / 2
|
@sprites["trainer"].oy = @sprites["trainer"].bitmap.height / 2
|
||||||
if REMOVEBARS
|
if REMOVE_BARS_WHEN_SHOWING_TRAINER
|
||||||
@sprites["overlay"].bitmap.clear
|
@sprites["overlay"].bitmap.clear
|
||||||
@sprites["hallbars"].visible = false
|
@sprites["hallbars"].visible = false
|
||||||
end
|
end
|
||||||
@xmovement[@battlerIndex] = 0
|
@xmovement[@battlerIndex] = 0
|
||||||
@ymovement[@battlerIndex] = 0
|
@ymovement[@battlerIndex] = 0
|
||||||
if ANIMATION && !SINGLEROW # Trainer Animation
|
if ANIMATION && !SINGLE_ROW_OF_POKEMON # Trainer Animation
|
||||||
startpoint = Graphics.width / 2
|
startpoint = Graphics.width / 2
|
||||||
# 2 is the trainer speed
|
# 2 is the trainer speed
|
||||||
@xmovement[@battlerIndex] = (startpoint - @sprites["trainer"].x) / 2
|
@xmovement[@battlerIndex] = (startpoint - @sprites["trainer"].x) / 2
|
||||||
@sprites["trainer"].x = startpoint
|
@sprites["trainer"].x = startpoint
|
||||||
else
|
else
|
||||||
ENTRYWAITTIME.times do
|
timer_start = System.uptime
|
||||||
|
loop do
|
||||||
Graphics.update
|
Graphics.update
|
||||||
Input.update
|
Input.update
|
||||||
pbUpdate
|
pbUpdate
|
||||||
|
break if System.uptime - timer_start >= ENTRY_WAIT_TIME
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -319,16 +316,16 @@ class HallOfFame_Scene
|
|||||||
dexnumber = _ISPRINTF("No. {1:03d}", number)
|
dexnumber = _ISPRINTF("No. {1:03d}", number)
|
||||||
end
|
end
|
||||||
textPositions = [
|
textPositions = [
|
||||||
[dexnumber, 32, Graphics.height - 74, :left, BASECOLOR, SHADOWCOLOR],
|
[dexnumber, 32, Graphics.height - 74, :left, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR],
|
||||||
[pokename, Graphics.width - 192, Graphics.height - 74, :center, BASECOLOR, SHADOWCOLOR],
|
[pokename, Graphics.width - 192, Graphics.height - 74, :center, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR],
|
||||||
[_INTL("Lv. {1}", pokemon.egg? ? "?" : pokemon.level),
|
[_INTL("Lv. {1}", pokemon.egg? ? "?" : pokemon.level),
|
||||||
64, Graphics.height - 42, :left, BASECOLOR, SHADOWCOLOR],
|
64, Graphics.height - 42, :left, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR],
|
||||||
[_INTL("ID No. {1}", pokemon.egg? ? "?????" : idno),
|
[_INTL("ID No. {1}", pokemon.egg? ? "?????" : idno),
|
||||||
Graphics.width - 192, Graphics.height - 42, :center, BASECOLOR, SHADOWCOLOR]
|
Graphics.width - 192, Graphics.height - 42, :center, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR]
|
||||||
]
|
]
|
||||||
if hallNumber > -1
|
if hallNumber > -1
|
||||||
textPositions.push([_INTL("Hall of Fame No."), (Graphics.width / 2) - 104, 6, :left, BASECOLOR, SHADOWCOLOR])
|
textPositions.push([_INTL("Hall of Fame No."), (Graphics.width / 2) - 104, 6, :left, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR])
|
||||||
textPositions.push([hallNumber.to_s, (Graphics.width / 2) + 104, 6, :right, BASECOLOR, SHADOWCOLOR])
|
textPositions.push([hallNumber.to_s, (Graphics.width / 2) + 104, 6, :right, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR])
|
||||||
end
|
end
|
||||||
pbDrawTextPositions(overlay, textPositions)
|
pbDrawTextPositions(overlay, textPositions)
|
||||||
end
|
end
|
||||||
@@ -337,7 +334,7 @@ class HallOfFame_Scene
|
|||||||
overlay = @sprites["overlay"].bitmap
|
overlay = @sprites["overlay"].bitmap
|
||||||
overlay.clear
|
overlay.clear
|
||||||
pbDrawTextPositions(overlay, [[_INTL("Welcome to the Hall of Fame!"),
|
pbDrawTextPositions(overlay, [[_INTL("Welcome to the Hall of Fame!"),
|
||||||
Graphics.width / 2, Graphics.height - 68, :center, BASECOLOR, SHADOWCOLOR]])
|
Graphics.width / 2, Graphics.height - 68, :center, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR]])
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbAnimationLoop
|
def pbAnimationLoop
|
||||||
@@ -386,26 +383,30 @@ class HallOfFame_Scene
|
|||||||
@battlerIndex += 1
|
@battlerIndex += 1
|
||||||
if @battlerIndex <= @hallEntry.size
|
if @battlerIndex <= @hallEntry.size
|
||||||
# If it is a pokémon, write the pokémon text, wait the
|
# If it is a pokémon, write the pokémon text, wait the
|
||||||
# ENTRYWAITTIME and goes to the next battler
|
# ENTRY_WAIT_TIME and goes to the next battler
|
||||||
@hallEntry[@battlerIndex - 1].play_cry
|
@hallEntry[@battlerIndex - 1].play_cry
|
||||||
writePokemonData(@hallEntry[@battlerIndex - 1])
|
writePokemonData(@hallEntry[@battlerIndex - 1])
|
||||||
(ENTRYWAITTIME * Graphics.frame_rate / 20).times do
|
timer_start = System.uptime
|
||||||
|
loop do
|
||||||
Graphics.update
|
Graphics.update
|
||||||
Input.update
|
Input.update
|
||||||
pbUpdate
|
pbUpdate
|
||||||
|
break if System.uptime - timer_start >= ENTRY_WAIT_TIME
|
||||||
end
|
end
|
||||||
if @battlerIndex < @hallEntry.size # Preparates the next battler
|
if @battlerIndex < @hallEntry.size # Preparates the next battler
|
||||||
setPokemonSpritesOpacity(@battlerIndex, OPACITY)
|
setPokemonSpritesOpacity(@battlerIndex, OPACITY)
|
||||||
@sprites["overlay"].bitmap.clear
|
@sprites["overlay"].bitmap.clear
|
||||||
else # Show the welcome message and preparates the trainer
|
else # Show the welcome message and prepares the trainer
|
||||||
setPokemonSpritesOpacity(-1)
|
setPokemonSpritesOpacity(-1)
|
||||||
writeWelcome
|
writeWelcome
|
||||||
(ENTRYWAITTIME * 2 * Graphics.frame_rate / 20).times do
|
timer_start = System.uptime
|
||||||
|
loop do
|
||||||
Graphics.update
|
Graphics.update
|
||||||
Input.update
|
Input.update
|
||||||
pbUpdate
|
pbUpdate
|
||||||
|
break if System.uptime - timer_start >= ENTRY_WAIT_TIME * 2
|
||||||
end
|
end
|
||||||
setPokemonSpritesOpacity(-1, OPACITY) if !SINGLEROW
|
setPokemonSpritesOpacity(-1, OPACITY) if !SINGLE_ROW_OF_POKEMON
|
||||||
createTrainerBattler
|
createTrainerBattler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -413,14 +414,15 @@ class HallOfFame_Scene
|
|||||||
elsif @battlerIndex > @hallEntry.size
|
elsif @battlerIndex > @hallEntry.size
|
||||||
# Write the trainer data and fade
|
# Write the trainer data and fade
|
||||||
writeTrainerData
|
writeTrainerData
|
||||||
(ENTRYWAITTIME * Graphics.frame_rate / 20).times do
|
timer_start = System.uptime
|
||||||
|
loop do
|
||||||
Graphics.update
|
Graphics.update
|
||||||
Input.update
|
Input.update
|
||||||
pbUpdate
|
pbUpdate
|
||||||
|
break if System.uptime - timer_start >= ENTRY_WAIT_TIME
|
||||||
end
|
end
|
||||||
fadeSpeed = ((Math.log(2**12) - Math.log(FINALFADESPEED)) / Math.log(2)).floor
|
pbBGMFade(FINAL_FADE_DURATION) if @useMusic
|
||||||
pbBGMFade((2**fadeSpeed).to_f / 20) if @useMusic
|
slowFadeOut(FINAL_FADE_DURATION)
|
||||||
slowFadeOut(@sprites, fadeSpeed) { pbUpdate }
|
|
||||||
@alreadyFadedInEnd = true
|
@alreadyFadedInEnd = true
|
||||||
@battlerIndex += 1
|
@battlerIndex += 1
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -124,8 +124,12 @@ class PokemonPokedexInfo_Scene
|
|||||||
|
|
||||||
def pbUpdate
|
def pbUpdate
|
||||||
if @page == 2
|
if @page == 2
|
||||||
intensity = (Graphics.frame_count % 40) * 12
|
intensity_time = System.uptime % 1.0 # 1 second per glow
|
||||||
intensity = 480 - intensity if intensity > 240
|
if intensity_time >= 0.5
|
||||||
|
intensity = lerp(64, 256 + 64, 0.5, intensity_time - 0.5)
|
||||||
|
else
|
||||||
|
intensity = lerp(256 + 64, 64, 0.5, intensity_time)
|
||||||
|
end
|
||||||
@sprites["areahighlight"].opacity = intensity
|
@sprites["areahighlight"].opacity = intensity
|
||||||
end
|
end
|
||||||
pbUpdateSpriteHash(@sprites)
|
pbUpdateSpriteHash(@sprites)
|
||||||
|
|||||||
@@ -108,9 +108,32 @@ end
|
|||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class AutoMosaicPokemonSprite < MosaicPokemonSprite
|
class AutoMosaicPokemonSprite < MosaicPokemonSprite
|
||||||
|
INITIAL_MOSAIC = 10 # Pixellation factor
|
||||||
|
|
||||||
|
def mosaic=(value)
|
||||||
|
@mosaic = value
|
||||||
|
@mosaic = 0 if @mosaic < 0
|
||||||
|
@start_mosaic = @mosaic if !@start_mosaic
|
||||||
|
end
|
||||||
|
|
||||||
|
def mosaic_duration=(val)
|
||||||
|
@mosaic_duration = val
|
||||||
|
@mosaic_duration = 0 if @mosaic_duration < 0
|
||||||
|
@mosaic_timer_start = System.uptime if @mosaic_duration > 0
|
||||||
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
super
|
super
|
||||||
self.mosaic -= 1
|
if @mosaic_timer_start
|
||||||
|
@start_mosaic = INITIAL_MOSAIC if !@start_mosaic || @start_mosaic == 0
|
||||||
|
new_mosaic = lerp(@start_mosaic, 0, @mosaic_duration, @mosaic_timer_start, System.uptime).to_i
|
||||||
|
self.mosaic = new_mosaic
|
||||||
|
mosaicRefresh(@oldbitmap)
|
||||||
|
if new_mosaic == 0
|
||||||
|
@mosaic_timer_start = nil
|
||||||
|
@start_mosaic = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -120,14 +143,15 @@ end
|
|||||||
class PokemonBoxArrow < Sprite
|
class PokemonBoxArrow < Sprite
|
||||||
attr_accessor :quickswap
|
attr_accessor :quickswap
|
||||||
|
|
||||||
|
# Time in seconds for the cursor to move down and back up to grab/drop a
|
||||||
|
# Pokémon.
|
||||||
|
GRAB_TIME = 0.4
|
||||||
|
|
||||||
def initialize(viewport = nil)
|
def initialize(viewport = nil)
|
||||||
super(viewport)
|
super(viewport)
|
||||||
@frame = 0
|
|
||||||
@holding = false
|
@holding = false
|
||||||
@updating = false
|
@updating = false
|
||||||
@quickswap = false
|
@quickswap = false
|
||||||
@grabbingState = 0
|
|
||||||
@placingState = 0
|
|
||||||
@heldpkmn = nil
|
@heldpkmn = nil
|
||||||
@handsprite = ChangelingSprite.new(0, 0, viewport)
|
@handsprite = ChangelingSprite.new(0, 0, viewport)
|
||||||
@handsprite.addBitmap("point1", "Graphics/UI/Storage/cursor_point_1")
|
@handsprite.addBitmap("point1", "Graphics/UI/Storage/cursor_point_1")
|
||||||
@@ -149,38 +173,6 @@ class PokemonBoxArrow < Sprite
|
|||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def heldPokemon
|
|
||||||
@heldpkmn = nil if @heldpkmn&.disposed?
|
|
||||||
@holding = false if !@heldpkmn
|
|
||||||
return @heldpkmn
|
|
||||||
end
|
|
||||||
|
|
||||||
def visible=(value)
|
|
||||||
super
|
|
||||||
@handsprite.visible = value
|
|
||||||
sprite = heldPokemon
|
|
||||||
sprite.visible = value if sprite
|
|
||||||
end
|
|
||||||
|
|
||||||
def color=(value)
|
|
||||||
super
|
|
||||||
@handsprite.color = value
|
|
||||||
sprite = heldPokemon
|
|
||||||
sprite.color = value if sprite
|
|
||||||
end
|
|
||||||
|
|
||||||
def holding?
|
|
||||||
return self.heldPokemon && @holding
|
|
||||||
end
|
|
||||||
|
|
||||||
def grabbing?
|
|
||||||
return @grabbingState > 0
|
|
||||||
end
|
|
||||||
|
|
||||||
def placing?
|
|
||||||
return @placingState > 0
|
|
||||||
end
|
|
||||||
|
|
||||||
def x=(value)
|
def x=(value)
|
||||||
super
|
super
|
||||||
@handsprite.x = self.x
|
@handsprite.x = self.x
|
||||||
@@ -200,6 +192,38 @@ class PokemonBoxArrow < Sprite
|
|||||||
@handsprite.z = value
|
@handsprite.z = value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def visible=(value)
|
||||||
|
super
|
||||||
|
@handsprite.visible = value
|
||||||
|
sprite = heldPokemon
|
||||||
|
sprite.visible = value if sprite
|
||||||
|
end
|
||||||
|
|
||||||
|
def color=(value)
|
||||||
|
super
|
||||||
|
@handsprite.color = value
|
||||||
|
sprite = heldPokemon
|
||||||
|
sprite.color = value if sprite
|
||||||
|
end
|
||||||
|
|
||||||
|
def heldPokemon
|
||||||
|
@heldpkmn = nil if @heldpkmn&.disposed?
|
||||||
|
@holding = false if !@heldpkmn
|
||||||
|
return @heldpkmn
|
||||||
|
end
|
||||||
|
|
||||||
|
def holding?
|
||||||
|
return self.heldPokemon && @holding
|
||||||
|
end
|
||||||
|
|
||||||
|
def grabbing?
|
||||||
|
return !@grabbing_timer_start.nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
def placing?
|
||||||
|
return !@placing_timer_start.nil?
|
||||||
|
end
|
||||||
|
|
||||||
def setSprite(sprite)
|
def setSprite(sprite)
|
||||||
if holding?
|
if holding?
|
||||||
@heldpkmn = sprite
|
@heldpkmn = sprite
|
||||||
@@ -219,7 +243,7 @@ class PokemonBoxArrow < Sprite
|
|||||||
end
|
end
|
||||||
|
|
||||||
def grab(sprite)
|
def grab(sprite)
|
||||||
@grabbingState = 1
|
@grabbing_timer_start = System.uptime
|
||||||
@heldpkmn = sprite
|
@heldpkmn = sprite
|
||||||
@heldpkmn.viewport = self.viewport
|
@heldpkmn.viewport = self.viewport
|
||||||
@heldpkmn.z = 1
|
@heldpkmn.z = 1
|
||||||
@@ -227,7 +251,7 @@ class PokemonBoxArrow < Sprite
|
|||||||
end
|
end
|
||||||
|
|
||||||
def place
|
def place
|
||||||
@placingState = 1
|
@placing_timer_start = System.uptime
|
||||||
end
|
end
|
||||||
|
|
||||||
def release
|
def release
|
||||||
@@ -241,46 +265,40 @@ class PokemonBoxArrow < Sprite
|
|||||||
heldpkmn&.update
|
heldpkmn&.update
|
||||||
@handsprite.update
|
@handsprite.update
|
||||||
@holding = false if !heldpkmn
|
@holding = false if !heldpkmn
|
||||||
if @grabbingState > 0
|
if @grabbing_timer_start
|
||||||
if @grabbingState <= 4 * Graphics.frame_rate / 20
|
if System.uptime - @grabbing_timer_start <= GRAB_TIME / 2
|
||||||
@handsprite.changeBitmap((@quickswap) ? "grabq" : "grab")
|
@handsprite.changeBitmap((@quickswap) ? "grabq" : "grab")
|
||||||
self.y = @spriteY + (4.0 * @grabbingState * 20 / Graphics.frame_rate)
|
self.y = @spriteY + lerp(0, 16, GRAB_TIME / 2, @grabbing_timer_start, System.uptime)
|
||||||
@grabbingState += 1
|
else
|
||||||
elsif @grabbingState <= 8 * Graphics.frame_rate / 20
|
|
||||||
@holding = true
|
@holding = true
|
||||||
@handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
|
@handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
|
||||||
self.y = @spriteY + (4 * ((8 * Graphics.frame_rate / 20) - @grabbingState) * 20 / Graphics.frame_rate)
|
delta_y = lerp(16, 0, GRAB_TIME / 2, @grabbing_timer_start + (GRAB_TIME / 2), System.uptime)
|
||||||
@grabbingState += 1
|
self.y = @spriteY + delta_y
|
||||||
else
|
@grabbing_timer_start = nil if delta_y == 0
|
||||||
@grabbingState = 0
|
|
||||||
end
|
end
|
||||||
elsif @placingState > 0
|
elsif @placing_timer_start
|
||||||
if @placingState <= 4 * Graphics.frame_rate / 20
|
if System.uptime - @placing_timer_start <= GRAB_TIME / 2
|
||||||
@handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
|
@handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
|
||||||
self.y = @spriteY + (4.0 * @placingState * 20 / Graphics.frame_rate)
|
self.y = @spriteY + lerp(0, 16, GRAB_TIME / 2, @placing_timer_start, System.uptime)
|
||||||
@placingState += 1
|
else
|
||||||
elsif @placingState <= 8 * Graphics.frame_rate / 20
|
|
||||||
@holding = false
|
@holding = false
|
||||||
@heldpkmn = nil
|
@heldpkmn = nil
|
||||||
@handsprite.changeBitmap((@quickswap) ? "grabq" : "grab")
|
@handsprite.changeBitmap((@quickswap) ? "grabq" : "grab")
|
||||||
self.y = @spriteY + (4 * ((8 * Graphics.frame_rate / 20) - @placingState) * 20 / Graphics.frame_rate)
|
delta_y = lerp(16, 0, GRAB_TIME / 2, @placing_timer_start + (GRAB_TIME / 2), System.uptime)
|
||||||
@placingState += 1
|
self.y = @spriteY + delta_y
|
||||||
else
|
@placing_timer_start = nil if delta_y == 0
|
||||||
@placingState = 0
|
|
||||||
end
|
end
|
||||||
elsif holding?
|
elsif holding?
|
||||||
@handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
|
@handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
|
||||||
else
|
else # Idling
|
||||||
self.x = @spriteX
|
self.x = @spriteX
|
||||||
self.y = @spriteY
|
self.y = @spriteY
|
||||||
if @frame < Graphics.frame_rate / 2
|
if (System.uptime / 0.5).to_i.even? # Changes every 0.5 seconds
|
||||||
@handsprite.changeBitmap((@quickswap) ? "point1q" : "point1")
|
@handsprite.changeBitmap((@quickswap) ? "point1q" : "point1")
|
||||||
else
|
else
|
||||||
@handsprite.changeBitmap((@quickswap) ? "point2q" : "point2")
|
@handsprite.changeBitmap((@quickswap) ? "point2q" : "point2")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@frame += 1
|
|
||||||
@frame = 0 if @frame >= Graphics.frame_rate
|
|
||||||
@updating = false
|
@updating = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -902,7 +920,7 @@ class PokemonStorageScene
|
|||||||
ret = pbSelectPartyInternal(party, false)
|
ret = pbSelectPartyInternal(party, false)
|
||||||
if ret < 0
|
if ret < 0
|
||||||
pbHidePartyTab
|
pbHidePartyTab
|
||||||
@selection = 0
|
@selection = -2
|
||||||
@choseFromParty = false
|
@choseFromParty = false
|
||||||
else
|
else
|
||||||
@choseFromParty = true
|
@choseFromParty = true
|
||||||
@@ -997,44 +1015,38 @@ class PokemonStorageScene
|
|||||||
Input.update
|
Input.update
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbSwitchBoxToRight(newbox)
|
def pbSwitchBoxToRight(new_box_number)
|
||||||
newbox = PokemonBoxSprite.new(@storage, newbox, @boxviewport)
|
start_x = @sprites["box"].x
|
||||||
newbox.x = 520
|
newbox = PokemonBoxSprite.new(@storage, new_box_number, @boxviewport)
|
||||||
Graphics.frame_reset
|
newbox.x = start_x + 336
|
||||||
distancePerFrame = 64 * 20 / Graphics.frame_rate
|
timer_start = System.uptime
|
||||||
loop do
|
loop do
|
||||||
Graphics.update
|
@sprites["box"].x = lerp(start_x, start_x - 336, 0.25, timer_start, System.uptime)
|
||||||
Input.update
|
newbox.x = @sprites["box"].x + 336
|
||||||
@sprites["box"].x -= distancePerFrame
|
|
||||||
newbox.x -= distancePerFrame
|
|
||||||
self.update
|
self.update
|
||||||
break if newbox.x <= 184
|
Graphics.update
|
||||||
|
break if newbox.x == start_x
|
||||||
end
|
end
|
||||||
diff = newbox.x - 184
|
|
||||||
newbox.x = 184
|
|
||||||
@sprites["box"].x -= diff
|
|
||||||
@sprites["box"].dispose
|
@sprites["box"].dispose
|
||||||
@sprites["box"] = newbox
|
@sprites["box"] = newbox
|
||||||
|
Input.update
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbSwitchBoxToLeft(newbox)
|
def pbSwitchBoxToLeft(new_box_number)
|
||||||
newbox = PokemonBoxSprite.new(@storage, newbox, @boxviewport)
|
start_x = @sprites["box"].x
|
||||||
newbox.x = -152
|
newbox = PokemonBoxSprite.new(@storage, new_box_number, @boxviewport)
|
||||||
Graphics.frame_reset
|
newbox.x = start_x - 336
|
||||||
distancePerFrame = 64 * 20 / Graphics.frame_rate
|
timer_start = System.uptime
|
||||||
loop do
|
loop do
|
||||||
Graphics.update
|
@sprites["box"].x = lerp(start_x, start_x + 336, 0.25, timer_start, System.uptime)
|
||||||
Input.update
|
newbox.x = @sprites["box"].x - 336
|
||||||
@sprites["box"].x += distancePerFrame
|
|
||||||
newbox.x += distancePerFrame
|
|
||||||
self.update
|
self.update
|
||||||
break if newbox.x >= 184
|
Graphics.update
|
||||||
|
break if newbox.x == start_x
|
||||||
end
|
end
|
||||||
diff = newbox.x - 184
|
|
||||||
newbox.x = 184
|
|
||||||
@sprites["box"].x -= diff
|
|
||||||
@sprites["box"].dispose
|
@sprites["box"].dispose
|
||||||
@sprites["box"] = newbox
|
@sprites["box"] = newbox
|
||||||
|
Input.update
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbJumpToBox(newbox)
|
def pbJumpToBox(newbox)
|
||||||
@@ -1050,7 +1062,7 @@ class PokemonStorageScene
|
|||||||
def pbSetMosaic(selection)
|
def pbSetMosaic(selection)
|
||||||
return if @screen.pbHeldPokemon
|
return if @screen.pbHeldPokemon
|
||||||
return if @boxForMosaic == @storage.currentBox && @selectionForMosaic == selection
|
return if @boxForMosaic == @storage.currentBox && @selectionForMosaic == selection
|
||||||
@sprites["pokemon"].mosaic = Graphics.frame_rate / 4
|
@sprites["pokemon"].mosaic_duration = 0.25 # In seconds
|
||||||
@boxForMosaic = @storage.currentBox
|
@boxForMosaic = @storage.currentBox
|
||||||
@selectionForMosaic = selection
|
@selectionForMosaic = selection
|
||||||
end
|
end
|
||||||
@@ -1061,29 +1073,43 @@ class PokemonStorageScene
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pbShowPartyTab
|
def pbShowPartyTab
|
||||||
pbSEPlay("GUI storage show party panel")
|
@sprites["arrow"].visible = false
|
||||||
distancePerFrame = 48 * 20 / Graphics.frame_rate
|
if !@screen.pbHeldPokemon
|
||||||
loop do
|
pbUpdateOverlay(-1)
|
||||||
Graphics.update
|
pbSetMosaic(-1)
|
||||||
Input.update
|
|
||||||
@sprites["boxparty"].y -= distancePerFrame
|
|
||||||
self.update
|
|
||||||
break if @sprites["boxparty"].y <= Graphics.height - 352
|
|
||||||
end
|
end
|
||||||
@sprites["boxparty"].y = Graphics.height - 352
|
pbSEPlay("GUI storage show party panel")
|
||||||
|
start_y = @sprites["boxparty"].y # Graphics.height
|
||||||
|
timer_start = System.uptime
|
||||||
|
loop do
|
||||||
|
@sprites["boxparty"].y = lerp(start_y, start_y - @sprites["boxparty"].height,
|
||||||
|
0.4, timer_start, System.uptime)
|
||||||
|
self.update
|
||||||
|
Graphics.update
|
||||||
|
break if @sprites["boxparty"].y == start_y - @sprites["boxparty"].height
|
||||||
|
end
|
||||||
|
Input.update
|
||||||
|
@sprites["arrow"].visible = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbHidePartyTab
|
def pbHidePartyTab
|
||||||
pbSEPlay("GUI storage hide party panel")
|
@sprites["arrow"].visible = false
|
||||||
distancePerFrame = 48 * 20 / Graphics.frame_rate
|
if !@screen.pbHeldPokemon
|
||||||
loop do
|
pbUpdateOverlay(-1)
|
||||||
Graphics.update
|
pbSetMosaic(-1)
|
||||||
Input.update
|
|
||||||
@sprites["boxparty"].y += distancePerFrame
|
|
||||||
self.update
|
|
||||||
break if @sprites["boxparty"].y >= Graphics.height
|
|
||||||
end
|
end
|
||||||
@sprites["boxparty"].y = Graphics.height
|
pbSEPlay("GUI storage hide party panel")
|
||||||
|
start_y = @sprites["boxparty"].y # Graphics.height - @sprites["boxparty"].height
|
||||||
|
timer_start = System.uptime
|
||||||
|
loop do
|
||||||
|
@sprites["boxparty"].y = lerp(start_y, start_y + @sprites["boxparty"].height,
|
||||||
|
0.4, timer_start, System.uptime)
|
||||||
|
self.update
|
||||||
|
Graphics.update
|
||||||
|
break if @sprites["boxparty"].y == start_y + @sprites["boxparty"].height
|
||||||
|
end
|
||||||
|
Input.update
|
||||||
|
@sprites["arrow"].visible = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbHold(selected)
|
def pbHold(selected)
|
||||||
@@ -1115,7 +1141,7 @@ class PokemonStorageScene
|
|||||||
@sprites["box"].setPokemon(selected[1], heldpokesprite)
|
@sprites["box"].setPokemon(selected[1], heldpokesprite)
|
||||||
end
|
end
|
||||||
@sprites["arrow"].setSprite(boxpokesprite)
|
@sprites["arrow"].setSprite(boxpokesprite)
|
||||||
@sprites["pokemon"].mosaic = 10
|
@sprites["pokemon"].mosaic_duration = 0.25 # In seconds
|
||||||
@boxForMosaic = @storage.currentBox
|
@boxForMosaic = @storage.currentBox
|
||||||
@selectionForMosaic = selected[1]
|
@selectionForMosaic = selected[1]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -479,7 +479,6 @@ class PokemonEntryScene2
|
|||||||
@sprites["controls"].x = 16
|
@sprites["controls"].x = 16
|
||||||
@sprites["controls"].y = 96
|
@sprites["controls"].y = 96
|
||||||
@sprites["controls"].setBitmap(_INTL("Graphics/UI/Naming/overlay_controls"))
|
@sprites["controls"].setBitmap(_INTL("Graphics/UI/Naming/overlay_controls"))
|
||||||
@init = true
|
|
||||||
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
|
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
|
||||||
pbDoUpdateOverlay2
|
pbDoUpdateOverlay2
|
||||||
@sprites["cursor"] = NameEntryCursor.new(@viewport)
|
@sprites["cursor"] = NameEntryCursor.new(@viewport)
|
||||||
@@ -556,16 +555,13 @@ class PokemonEntryScene2
|
|||||||
@@Characters.length.times do |i|
|
@@Characters.length.times do |i|
|
||||||
@bitmaps[i].update
|
@bitmaps[i].update
|
||||||
end
|
end
|
||||||
if @init || Graphics.frame_count % 5 == 0
|
# Update which inputted text's character's underline is lowered to indicate
|
||||||
@init = false
|
# which character is selected
|
||||||
cursorpos = @helper.cursor
|
cursorpos = @helper.cursor.clamp(0, @maxlength - 1)
|
||||||
cursorpos = @maxlength - 1 if cursorpos >= @maxlength
|
|
||||||
cursorpos = 0 if cursorpos < 0
|
|
||||||
@maxlength.times do |i|
|
@maxlength.times do |i|
|
||||||
@blanks[i] = (i == cursorpos) ? 1 : 0
|
@blanks[i] = (i == cursorpos) ? 1 : 0
|
||||||
@sprites["blank#{i}"].y = [78, 82][@blanks[i]]
|
@sprites["blank#{i}"].y = [78, 82][@blanks[i]]
|
||||||
end
|
end
|
||||||
end
|
|
||||||
pbDoUpdateOverlay
|
pbDoUpdateOverlay
|
||||||
pbUpdateSpriteHash(@sprites)
|
pbUpdateSpriteHash(@sprites)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user