Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =============================================================================
- # FFS - Ultimate Parallax Control
- # Kompatibel mit Khas Awesome Light & Effects
- # Von FlipelyFlip
- # =============================================================================
- class Spriteset_Map
- include GDS_Parallax::Parallax
- # ---------------------------------------------------------
- # Parallax-Erstellung erweitern
- # ---------------------------------------------------------
- alias ffs_create_parallax create_parallax
- def create_parallax
- ffs_create_parallax
- create_parallaxes
- @do_it1 = @do_it2 = @do_it3 = @do_it4 = true
- end
- # ---------------------------------------------------------
- # Parallax-Layer erstellen
- # ---------------------------------------------------------
- def create_parallaxes
- map = $game_map.map_id
- @maps = map
- @check1 = @check2 = @check3 = @check4 = true
- @fixed_p = false
- @create1 = Parallax2.include?(map)
- @create2 = Light.include?(map)
- @create3 = Shadow.include?(map)
- @create4 = Ground.include?(map)
- @fixed_p = FIXED_Parallax.include?(map)
- @parallax1 = Plane.new(@viewport1) if @create1
- @parallax1.z = 203 if @create1
- @parallax2 = Plane.new(@viewport1) if @create2
- @parallax2.z = 202 if @create2
- @parallax3 = Plane.new(@viewport1) if @create3
- @parallax3.z = 201 if @create3
- @parallax4 = Plane.new(@viewport1) if @create4
- @parallax4.z = 1 if @create4
- @on1 = @on2 = @on3 = @on4 = false
- end
- # ---------------------------------------------------------
- # Map-Wechsel erkennen (ohne Cache.clear!)
- # ---------------------------------------------------------
- def check_for_dispose
- if @maps != $game_map.map_id
- dispose_custom_layers
- create_parallaxes
- end
- end
- def dispose_custom_layers
- @parallax1.dispose if @parallax1 && [email protected]?
- @parallax2.dispose if @parallax2 && [email protected]?
- @parallax3.dispose if @parallax3 && [email protected]?
- @parallax4.dispose if @parallax4 && [email protected]?
- end
- # ---------------------------------------------------------
- # Standard-Parallax korrekt disposen
- # ---------------------------------------------------------
- alias ffs_dispose_parallax dispose_parallax
- def dispose_parallax
- dispose_custom_layers
- ffs_dispose_parallax
- end
- # ---------------------------------------------------------
- # Update – stabilisiert, race-condition-frei
- # ---------------------------------------------------------
- def update_parallax
- check_for_dispose
- # Sichtbarkeit über Switches
- @parallax1.visible = $game_switches[SWITCH_SKY] if SWITCH_SKY
- @parallax2.visible = $game_switches[SWITCH_LIGHT] if SWITCH_LIGHT
- @parallax3.visible = $game_switches[SWITCH_SHADOW] if SWITCH_SHADOW
- @parallax4.visible = $game_switches[SWITCH_GROUND] if SWITCH_GROUND
- # Standard-Parallax neu laden
- if @parallax_name != $game_map.parallax_name
- @parallax_name = $game_map.parallax_name
- if @parallax.bitmap && [email protected]?
- @parallax.bitmap.dispose
- end
- @parallax.bitmap = Cache.parallax(@parallax_name)
- Graphics.frame_reset
- end
- # -----------------------------------------------------
- # SKY Layer
- # -----------------------------------------------------
- if @create1 && (
- @check1 ||
- !@parallax1 ||
- @parallax1.disposed? ||
- @parallax1.bitmap.disposed?
- )
- ensure_plane(@parallax1, 203)
- sky = layer_name($game_map.map_id, VARIABLE_SKY, "_Layer2")
- @parallax1.bitmap = safe_parallax(sky)
- @check1 = false
- @on1 = true
- end
- # -----------------------------------------------------
- # LIGHT Layer
- # -----------------------------------------------------
- if @create2 && (
- @check2 ||
- !@parallax2 ||
- @parallax2.disposed? ||
- @parallax2.bitmap.disposed?
- )
- ensure_plane(@parallax2, 202)
- light = layer_name($game_map.map_id, VARIABLE_LIGHT, "_light")
- @parallax2.bitmap = safe_parallax(light)
- @check2 = false
- @on2 = true
- end
- # -----------------------------------------------------
- # SHADOW Layer
- # -----------------------------------------------------
- if @create3 && (
- @check3 ||
- !@parallax3 ||
- @parallax3.disposed? ||
- @parallax3.bitmap.disposed?
- )
- ensure_plane(@parallax3, 201)
- shadow = layer_name($game_map.map_id, VARIABLE_SHADOW, "_shadow")
- @parallax3.bitmap = safe_parallax(shadow)
- @check3 = false
- @on3 = true
- end
- # -----------------------------------------------------
- # GROUND Layer
- # -----------------------------------------------------
- if @create4 && (
- @check4 ||
- !@parallax4 ||
- @parallax4.disposed? ||
- @parallax4.bitmap.disposed?
- )
- ensure_plane(@parallax4, 1)
- ground = layer_name($game_map.map_id, VARIABLE_GROUND, "_Ground")
- @parallax4.bitmap = safe_parallax(ground)
- @check4 = false
- @on4 = true
- end
- # -----------------------------------------------------
- # Bewegung
- # -----------------------------------------------------
- @parallax1.ox = $game_map.display_x * 32 if @create1
- @parallax1.oy = $game_map.display_y * 32 if @create1
- @parallax2.ox = $game_map.display_x * 32 + rand(Flicker_Light) if @create2
- @parallax2.oy = $game_map.display_y * 32 + rand(Flicker_Light) if @create2
- @parallax3.ox = $game_map.display_x * 32 + rand(Flicker_Shadow) if @create3
- @parallax3.oy = $game_map.display_y * 32 + rand(Flicker_Shadow) if @create3
- @parallax4.ox = $game_map.display_x * 32 if @create4
- @parallax4.oy = $game_map.display_y * 32 if @create4
- # Standard-Parallax
- if @fixed_p
- @parallax.ox = $game_map.parallax_ox(@parallax.bitmap)
- @parallax.oy = $game_map.parallax_oy(@parallax.bitmap)
- else
- @parallax.ox = $game_map.display_x * 32
- @parallax.oy = $game_map.display_y * 32
- end
- end
- # ---------------------------------------------------------
- # Hilfsfunktionen
- # ---------------------------------------------------------
- def ensure_plane(plane, z)
- if !plane || plane.disposed?
- plane = Plane.new(@viewport1)
- plane.z = z
- end
- plane
- end
- def layer_name(id, var, suffix)
- if var && $game_variables[var] != 0
- "#{id}-#{$game_variables[var]}#{suffix}"
- else
- "#{id}#{suffix}"
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment