Advertisement
TechSkylander1518

Polished Floors (v20)

Dec 23rd, 2022
1,521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.30 KB | None | 0 0
  1. module GameData
  2.   class TerrainTag
  3.     attr_reader :ripples
  4.  
  5.     alias oldinitialize initialize
  6.     def initialize(hash)
  7.       oldinitialize(hash)
  8.       @ripples           = hash[:ripples]            || true
  9.     end
  10.  
  11.   end
  12. end
  13.  
  14. class Sprite_Reflection
  15.  
  16.   def update
  17.     return if disposed?
  18.     shouldShow = @rsprite.visible
  19.     if !shouldShow
  20.       # Just-in-time disposal of sprite
  21.       if @sprite
  22.         @sprite.dispose
  23.         @sprite = nil
  24.       end
  25.       return
  26.     end
  27.     # Just-in-time creation of sprite
  28.     @sprite = Sprite.new(@viewport) if !@sprite
  29.     if @sprite
  30.       x = @rsprite.x - @rsprite.ox * TilemapRenderer::ZOOM_X
  31.       y = @rsprite.y - @rsprite.oy * TilemapRenderer::ZOOM_Y
  32.       y -= Game_Map::TILE_HEIGHT * TilemapRenderer::ZOOM_Y if @rsprite.character.character_name[/offset/i]
  33.       @height = $PokemonGlobal.bridge if !@fixedheight
  34.       y += @height * TilemapRenderer::ZOOM_Y * Game_Map::TILE_HEIGHT / 2
  35.       width  = @rsprite.src_rect.width
  36.       height = @rsprite.src_rect.height
  37.       @sprite.x        = x + (width / 2) * TilemapRenderer::ZOOM_X
  38.       @sprite.y        = y + (height + (height / 2)) * TilemapRenderer::ZOOM_Y
  39.       @sprite.ox       = width / 2
  40.       @sprite.oy       = (height / 2) - 2   # Hard-coded 2 pixel shift up
  41.       @sprite.oy       -= @rsprite.character.bob_height * 2
  42.       @sprite.z        = -50   # Still water is -100, map is 0 and above
  43.       @sprite.z        += 1 if @event == $game_player
  44.       @sprite.zoom_x   = @rsprite.zoom_x
  45.       @sprite.zoom_y   = @rsprite.zoom_y
  46.       frame = (Graphics.frame_count % 40) / 10
  47.       ripples = @event.terrain_tag.ripples if @event
  48.       @sprite.zoom_x   *= [1.0, 0.95, 1.0, 1.05][frame] if ripples
  49.       @sprite.angle    = 180.0
  50.       @sprite.mirror   = true
  51.       @sprite.bitmap   = @rsprite.bitmap
  52.       @sprite.tone     = @rsprite.tone
  53.       if @height > 0
  54.         @sprite.color   = Color.new(48, 96, 160, 255)   # Dark still water
  55.         @sprite.opacity = @rsprite.opacity
  56.         @sprite.visible = !Settings::TIME_SHADING   # Can't time-tone a colored sprite
  57.       else
  58.         @sprite.color   = Color.new(224, 224, 224, 96)
  59.         @sprite.opacity = @rsprite.opacity * 3 / 4
  60.         @sprite.visible = true
  61.       end
  62.       @sprite.src_rect = @rsprite.src_rect
  63.     end
  64.   end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement