mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 06:04:59 +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:
@@ -108,9 +108,32 @@ end
|
||||
#
|
||||
#===============================================================================
|
||||
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
|
||||
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
|
||||
|
||||
@@ -120,16 +143,17 @@ end
|
||||
class PokemonBoxArrow < Sprite
|
||||
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)
|
||||
super(viewport)
|
||||
@frame = 0
|
||||
@holding = false
|
||||
@updating = false
|
||||
@quickswap = false
|
||||
@grabbingState = 0
|
||||
@placingState = 0
|
||||
@heldpkmn = nil
|
||||
@handsprite = ChangelingSprite.new(0, 0, viewport)
|
||||
@holding = false
|
||||
@updating = false
|
||||
@quickswap = false
|
||||
@heldpkmn = nil
|
||||
@handsprite = ChangelingSprite.new(0, 0, viewport)
|
||||
@handsprite.addBitmap("point1", "Graphics/UI/Storage/cursor_point_1")
|
||||
@handsprite.addBitmap("point2", "Graphics/UI/Storage/cursor_point_2")
|
||||
@handsprite.addBitmap("grab", "Graphics/UI/Storage/cursor_grab")
|
||||
@@ -149,38 +173,6 @@ class PokemonBoxArrow < Sprite
|
||||
super
|
||||
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)
|
||||
super
|
||||
@handsprite.x = self.x
|
||||
@@ -200,6 +192,38 @@ class PokemonBoxArrow < Sprite
|
||||
@handsprite.z = value
|
||||
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)
|
||||
if holding?
|
||||
@heldpkmn = sprite
|
||||
@@ -219,7 +243,7 @@ class PokemonBoxArrow < Sprite
|
||||
end
|
||||
|
||||
def grab(sprite)
|
||||
@grabbingState = 1
|
||||
@grabbing_timer_start = System.uptime
|
||||
@heldpkmn = sprite
|
||||
@heldpkmn.viewport = self.viewport
|
||||
@heldpkmn.z = 1
|
||||
@@ -227,7 +251,7 @@ class PokemonBoxArrow < Sprite
|
||||
end
|
||||
|
||||
def place
|
||||
@placingState = 1
|
||||
@placing_timer_start = System.uptime
|
||||
end
|
||||
|
||||
def release
|
||||
@@ -241,46 +265,40 @@ class PokemonBoxArrow < Sprite
|
||||
heldpkmn&.update
|
||||
@handsprite.update
|
||||
@holding = false if !heldpkmn
|
||||
if @grabbingState > 0
|
||||
if @grabbingState <= 4 * Graphics.frame_rate / 20
|
||||
if @grabbing_timer_start
|
||||
if System.uptime - @grabbing_timer_start <= GRAB_TIME / 2
|
||||
@handsprite.changeBitmap((@quickswap) ? "grabq" : "grab")
|
||||
self.y = @spriteY + (4.0 * @grabbingState * 20 / Graphics.frame_rate)
|
||||
@grabbingState += 1
|
||||
elsif @grabbingState <= 8 * Graphics.frame_rate / 20
|
||||
self.y = @spriteY + lerp(0, 16, GRAB_TIME / 2, @grabbing_timer_start, System.uptime)
|
||||
else
|
||||
@holding = true
|
||||
@handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
|
||||
self.y = @spriteY + (4 * ((8 * Graphics.frame_rate / 20) - @grabbingState) * 20 / Graphics.frame_rate)
|
||||
@grabbingState += 1
|
||||
else
|
||||
@grabbingState = 0
|
||||
delta_y = lerp(16, 0, GRAB_TIME / 2, @grabbing_timer_start + (GRAB_TIME / 2), System.uptime)
|
||||
self.y = @spriteY + delta_y
|
||||
@grabbing_timer_start = nil if delta_y == 0
|
||||
end
|
||||
elsif @placingState > 0
|
||||
if @placingState <= 4 * Graphics.frame_rate / 20
|
||||
elsif @placing_timer_start
|
||||
if System.uptime - @placing_timer_start <= GRAB_TIME / 2
|
||||
@handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
|
||||
self.y = @spriteY + (4.0 * @placingState * 20 / Graphics.frame_rate)
|
||||
@placingState += 1
|
||||
elsif @placingState <= 8 * Graphics.frame_rate / 20
|
||||
self.y = @spriteY + lerp(0, 16, GRAB_TIME / 2, @placing_timer_start, System.uptime)
|
||||
else
|
||||
@holding = false
|
||||
@heldpkmn = nil
|
||||
@handsprite.changeBitmap((@quickswap) ? "grabq" : "grab")
|
||||
self.y = @spriteY + (4 * ((8 * Graphics.frame_rate / 20) - @placingState) * 20 / Graphics.frame_rate)
|
||||
@placingState += 1
|
||||
else
|
||||
@placingState = 0
|
||||
delta_y = lerp(16, 0, GRAB_TIME / 2, @placing_timer_start + (GRAB_TIME / 2), System.uptime)
|
||||
self.y = @spriteY + delta_y
|
||||
@placing_timer_start = nil if delta_y == 0
|
||||
end
|
||||
elsif holding?
|
||||
@handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
|
||||
else
|
||||
else # Idling
|
||||
self.x = @spriteX
|
||||
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")
|
||||
else
|
||||
@handsprite.changeBitmap((@quickswap) ? "point2q" : "point2")
|
||||
end
|
||||
end
|
||||
@frame += 1
|
||||
@frame = 0 if @frame >= Graphics.frame_rate
|
||||
@updating = false
|
||||
end
|
||||
end
|
||||
@@ -902,7 +920,7 @@ class PokemonStorageScene
|
||||
ret = pbSelectPartyInternal(party, false)
|
||||
if ret < 0
|
||||
pbHidePartyTab
|
||||
@selection = 0
|
||||
@selection = -2
|
||||
@choseFromParty = false
|
||||
else
|
||||
@choseFromParty = true
|
||||
@@ -997,44 +1015,38 @@ class PokemonStorageScene
|
||||
Input.update
|
||||
end
|
||||
|
||||
def pbSwitchBoxToRight(newbox)
|
||||
newbox = PokemonBoxSprite.new(@storage, newbox, @boxviewport)
|
||||
newbox.x = 520
|
||||
Graphics.frame_reset
|
||||
distancePerFrame = 64 * 20 / Graphics.frame_rate
|
||||
def pbSwitchBoxToRight(new_box_number)
|
||||
start_x = @sprites["box"].x
|
||||
newbox = PokemonBoxSprite.new(@storage, new_box_number, @boxviewport)
|
||||
newbox.x = start_x + 336
|
||||
timer_start = System.uptime
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
@sprites["box"].x -= distancePerFrame
|
||||
newbox.x -= distancePerFrame
|
||||
@sprites["box"].x = lerp(start_x, start_x - 336, 0.25, timer_start, System.uptime)
|
||||
newbox.x = @sprites["box"].x + 336
|
||||
self.update
|
||||
break if newbox.x <= 184
|
||||
Graphics.update
|
||||
break if newbox.x == start_x
|
||||
end
|
||||
diff = newbox.x - 184
|
||||
newbox.x = 184
|
||||
@sprites["box"].x -= diff
|
||||
@sprites["box"].dispose
|
||||
@sprites["box"] = newbox
|
||||
Input.update
|
||||
end
|
||||
|
||||
def pbSwitchBoxToLeft(newbox)
|
||||
newbox = PokemonBoxSprite.new(@storage, newbox, @boxviewport)
|
||||
newbox.x = -152
|
||||
Graphics.frame_reset
|
||||
distancePerFrame = 64 * 20 / Graphics.frame_rate
|
||||
def pbSwitchBoxToLeft(new_box_number)
|
||||
start_x = @sprites["box"].x
|
||||
newbox = PokemonBoxSprite.new(@storage, new_box_number, @boxviewport)
|
||||
newbox.x = start_x - 336
|
||||
timer_start = System.uptime
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
@sprites["box"].x += distancePerFrame
|
||||
newbox.x += distancePerFrame
|
||||
@sprites["box"].x = lerp(start_x, start_x + 336, 0.25, timer_start, System.uptime)
|
||||
newbox.x = @sprites["box"].x - 336
|
||||
self.update
|
||||
break if newbox.x >= 184
|
||||
Graphics.update
|
||||
break if newbox.x == start_x
|
||||
end
|
||||
diff = newbox.x - 184
|
||||
newbox.x = 184
|
||||
@sprites["box"].x -= diff
|
||||
@sprites["box"].dispose
|
||||
@sprites["box"] = newbox
|
||||
Input.update
|
||||
end
|
||||
|
||||
def pbJumpToBox(newbox)
|
||||
@@ -1050,7 +1062,7 @@ class PokemonStorageScene
|
||||
def pbSetMosaic(selection)
|
||||
return if @screen.pbHeldPokemon
|
||||
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
|
||||
@selectionForMosaic = selection
|
||||
end
|
||||
@@ -1061,29 +1073,43 @@ class PokemonStorageScene
|
||||
end
|
||||
|
||||
def pbShowPartyTab
|
||||
pbSEPlay("GUI storage show party panel")
|
||||
distancePerFrame = 48 * 20 / Graphics.frame_rate
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
@sprites["boxparty"].y -= distancePerFrame
|
||||
self.update
|
||||
break if @sprites["boxparty"].y <= Graphics.height - 352
|
||||
@sprites["arrow"].visible = false
|
||||
if !@screen.pbHeldPokemon
|
||||
pbUpdateOverlay(-1)
|
||||
pbSetMosaic(-1)
|
||||
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
|
||||
|
||||
def pbHidePartyTab
|
||||
pbSEPlay("GUI storage hide party panel")
|
||||
distancePerFrame = 48 * 20 / Graphics.frame_rate
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
@sprites["boxparty"].y += distancePerFrame
|
||||
self.update
|
||||
break if @sprites["boxparty"].y >= Graphics.height
|
||||
@sprites["arrow"].visible = false
|
||||
if !@screen.pbHeldPokemon
|
||||
pbUpdateOverlay(-1)
|
||||
pbSetMosaic(-1)
|
||||
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
|
||||
|
||||
def pbHold(selected)
|
||||
@@ -1115,7 +1141,7 @@ class PokemonStorageScene
|
||||
@sprites["box"].setPokemon(selected[1], heldpokesprite)
|
||||
end
|
||||
@sprites["arrow"].setSprite(boxpokesprite)
|
||||
@sprites["pokemon"].mosaic = 10
|
||||
@sprites["pokemon"].mosaic_duration = 0.25 # In seconds
|
||||
@boxForMosaic = @storage.currentBox
|
||||
@selectionForMosaic = selected[1]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user