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

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

View File

@@ -2,13 +2,23 @@
# Walking charset, for use in text entry screens and load game screen
#===============================================================================
class TrainerWalkingCharSprite < Sprite
attr_accessor :anim_duration
# Default time in seconds for one animation cycle of a charset. The icon for a
# storage box is 0.4 instead (set manually).
ANIMATION_DURATION = 0.5
def initialize(charset, viewport = nil)
super(viewport)
@animbitmap = nil
self.charset = charset
@animframe = 0 # Current pattern
@frame = 0 # Frame counter
self.animspeed = 5 # Animation speed (frames per pattern)
@current_frame = 0 # Current pattern
@anim_duration = ANIMATION_DURATION
end
def dispose
@animbitmap&.dispose
super
end
def charset=(value)
@@ -38,13 +48,8 @@ class TrainerWalkingCharSprite < Sprite
end
end
def animspeed=(value)
@frameskip = value * Graphics.frame_rate / 40
end
def dispose
@animbitmap&.dispose
super
def update_frame
@current_frame = (4 * (System.uptime % @anim_duration) / @anim_duration).floor
end
def update
@@ -54,12 +59,9 @@ class TrainerWalkingCharSprite < Sprite
@animbitmap.update
self.bitmap = @animbitmap.bitmap
end
@frame += 1
if @frame >= @frameskip
@animframe = (@animframe + 1) % 4
self.src_rect.x = @animframe * @animbitmap.bitmap.width / 4
@frame -= @frameskip
end
# Update animation
update_frame
self.src_rect.x = self.src_rect.width * @current_frame
@updating = false
end
end