FlipelyFlip

FFS - Ultimate Parallax Control

Mar 31st, 2026
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.69 KB | None | 0 0
  1. # =============================================================================
  2. # FFS - Ultimate Parallax Control
  3. # Kompatibel mit Khas Awesome Light & Effects
  4. # Von FlipelyFlip
  5. # =============================================================================
  6.  
  7. class Spriteset_Map
  8. include GDS_Parallax::Parallax
  9.  
  10. # ---------------------------------------------------------
  11. # Parallax-Erstellung erweitern
  12. # ---------------------------------------------------------
  13. alias ffs_create_parallax create_parallax
  14. def create_parallax
  15. ffs_create_parallax
  16. create_parallaxes
  17. @do_it1 = @do_it2 = @do_it3 = @do_it4 = true
  18. end
  19.  
  20. # ---------------------------------------------------------
  21. # Parallax-Layer erstellen
  22. # ---------------------------------------------------------
  23. def create_parallaxes
  24. map = $game_map.map_id
  25. @maps = map
  26.  
  27. @check1 = @check2 = @check3 = @check4 = true
  28. @fixed_p = false
  29.  
  30. @create1 = Parallax2.include?(map)
  31. @create2 = Light.include?(map)
  32. @create3 = Shadow.include?(map)
  33. @create4 = Ground.include?(map)
  34.  
  35. @fixed_p = FIXED_Parallax.include?(map)
  36.  
  37. @parallax1 = Plane.new(@viewport1) if @create1
  38. @parallax1.z = 203 if @create1
  39.  
  40. @parallax2 = Plane.new(@viewport1) if @create2
  41. @parallax2.z = 202 if @create2
  42.  
  43. @parallax3 = Plane.new(@viewport1) if @create3
  44. @parallax3.z = 201 if @create3
  45.  
  46. @parallax4 = Plane.new(@viewport1) if @create4
  47. @parallax4.z = 1 if @create4
  48.  
  49. @on1 = @on2 = @on3 = @on4 = false
  50. end
  51.  
  52. # ---------------------------------------------------------
  53. # Map-Wechsel erkennen (ohne Cache.clear!)
  54. # ---------------------------------------------------------
  55. def check_for_dispose
  56. if @maps != $game_map.map_id
  57. dispose_custom_layers
  58. create_parallaxes
  59. end
  60. end
  61.  
  62. def dispose_custom_layers
  63. @parallax1.dispose if @parallax1 && [email protected]?
  64. @parallax2.dispose if @parallax2 && [email protected]?
  65. @parallax3.dispose if @parallax3 && [email protected]?
  66. @parallax4.dispose if @parallax4 && [email protected]?
  67. end
  68.  
  69. # ---------------------------------------------------------
  70. # Standard-Parallax korrekt disposen
  71. # ---------------------------------------------------------
  72. alias ffs_dispose_parallax dispose_parallax
  73. def dispose_parallax
  74. dispose_custom_layers
  75. ffs_dispose_parallax
  76. end
  77.  
  78. # ---------------------------------------------------------
  79. # Update – stabilisiert, race-condition-frei
  80. # ---------------------------------------------------------
  81. def update_parallax
  82. check_for_dispose
  83.  
  84. # Sichtbarkeit über Switches
  85. @parallax1.visible = $game_switches[SWITCH_SKY] if SWITCH_SKY
  86. @parallax2.visible = $game_switches[SWITCH_LIGHT] if SWITCH_LIGHT
  87. @parallax3.visible = $game_switches[SWITCH_SHADOW] if SWITCH_SHADOW
  88. @parallax4.visible = $game_switches[SWITCH_GROUND] if SWITCH_GROUND
  89.  
  90. # Standard-Parallax neu laden
  91. if @parallax_name != $game_map.parallax_name
  92. @parallax_name = $game_map.parallax_name
  93. if @parallax.bitmap && [email protected]?
  94. @parallax.bitmap.dispose
  95. end
  96. @parallax.bitmap = Cache.parallax(@parallax_name)
  97. Graphics.frame_reset
  98. end
  99.  
  100. # -----------------------------------------------------
  101. # SKY Layer
  102. # -----------------------------------------------------
  103. if @create1 && (
  104. @check1 ||
  105. !@parallax1 ||
  106. @parallax1.disposed? ||
  107. @parallax1.bitmap.disposed?
  108. )
  109. ensure_plane(@parallax1, 203)
  110. sky = layer_name($game_map.map_id, VARIABLE_SKY, "_Layer2")
  111. @parallax1.bitmap = safe_parallax(sky)
  112. @check1 = false
  113. @on1 = true
  114. end
  115.  
  116. # -----------------------------------------------------
  117. # LIGHT Layer
  118. # -----------------------------------------------------
  119. if @create2 && (
  120. @check2 ||
  121. !@parallax2 ||
  122. @parallax2.disposed? ||
  123. @parallax2.bitmap.disposed?
  124. )
  125. ensure_plane(@parallax2, 202)
  126. light = layer_name($game_map.map_id, VARIABLE_LIGHT, "_light")
  127. @parallax2.bitmap = safe_parallax(light)
  128. @check2 = false
  129. @on2 = true
  130. end
  131.  
  132. # -----------------------------------------------------
  133. # SHADOW Layer
  134. # -----------------------------------------------------
  135. if @create3 && (
  136. @check3 ||
  137. !@parallax3 ||
  138. @parallax3.disposed? ||
  139. @parallax3.bitmap.disposed?
  140. )
  141. ensure_plane(@parallax3, 201)
  142. shadow = layer_name($game_map.map_id, VARIABLE_SHADOW, "_shadow")
  143. @parallax3.bitmap = safe_parallax(shadow)
  144. @check3 = false
  145. @on3 = true
  146. end
  147.  
  148. # -----------------------------------------------------
  149. # GROUND Layer
  150. # -----------------------------------------------------
  151. if @create4 && (
  152. @check4 ||
  153. !@parallax4 ||
  154. @parallax4.disposed? ||
  155. @parallax4.bitmap.disposed?
  156. )
  157. ensure_plane(@parallax4, 1)
  158. ground = layer_name($game_map.map_id, VARIABLE_GROUND, "_Ground")
  159. @parallax4.bitmap = safe_parallax(ground)
  160. @check4 = false
  161. @on4 = true
  162. end
  163.  
  164. # -----------------------------------------------------
  165. # Bewegung
  166. # -----------------------------------------------------
  167. @parallax1.ox = $game_map.display_x * 32 if @create1
  168. @parallax1.oy = $game_map.display_y * 32 if @create1
  169.  
  170. @parallax2.ox = $game_map.display_x * 32 + rand(Flicker_Light) if @create2
  171. @parallax2.oy = $game_map.display_y * 32 + rand(Flicker_Light) if @create2
  172.  
  173. @parallax3.ox = $game_map.display_x * 32 + rand(Flicker_Shadow) if @create3
  174. @parallax3.oy = $game_map.display_y * 32 + rand(Flicker_Shadow) if @create3
  175.  
  176. @parallax4.ox = $game_map.display_x * 32 if @create4
  177. @parallax4.oy = $game_map.display_y * 32 if @create4
  178.  
  179. # Standard-Parallax
  180. if @fixed_p
  181. @parallax.ox = $game_map.parallax_ox(@parallax.bitmap)
  182. @parallax.oy = $game_map.parallax_oy(@parallax.bitmap)
  183. else
  184. @parallax.ox = $game_map.display_x * 32
  185. @parallax.oy = $game_map.display_y * 32
  186. end
  187. end
  188.  
  189. # ---------------------------------------------------------
  190. # Hilfsfunktionen
  191. # ---------------------------------------------------------
  192. def ensure_plane(plane, z)
  193. if !plane || plane.disposed?
  194. plane = Plane.new(@viewport1)
  195. plane.z = z
  196. end
  197. plane
  198. end
  199.  
  200. def layer_name(id, var, suffix)
  201. if var && $game_variables[var] != 0
  202. "#{id}-#{$game_variables[var]}#{suffix}"
  203. else
  204. "#{id}#{suffix}"
  205. end
  206. end
  207. end
  208.  
Advertisement
Add Comment
Please, Sign In to add comment