pigu_6

GDS| Ultimate parallax control

Nov 23rd, 2012
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.23 KB | None | 0 0
  1. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. # Ultimate Parallax Control V1.0
  3. #
  4. # By: GDS
  5. # Translate: Pigu
  6. #
  7. #==============================================================================
  8. # ▼ Updates
  9. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  10. # 2012.21.05 - Script istart and finish
  11. #
  12. #==============================================================================
  13. # ▼ Introduccion
  14. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  15. # Con este script tienes todas las funciones de parallaxes en uno
  16. # no necesita "script calls", <notetags> ni tampoco switches o variables
  17. # aunque estos ultimos si se pueden activar
  18. #
  19. #==============================================================================
  20. # CONFIGURACIONES
  21. #==============================================================================
  22. module GDS_Parallax
  23. module Parallax
  24. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  25. #All parallaxes are fixed by defaut now,
  26. #if want the default movement of the parallaxex just put the map id here
  27. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  28. FIXED_Parallax =[ #<=|Id of the map that will not be fixed
  29. ] #
  30. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  31. # Cielo,
  32. # Esta capa esta arriba de todas las demas, no tiene movimiento
  33. #
  34. # Para activarla necesitamos una imagen en \Graphics\Parallaxes
  35. # con el nombre "x"_layer2,
  36. # X es el numero de ID que lleva el mapa
  37. #
  38. # Ejemplo:
  39. # "\Graphics\Parallaxes\1_layer2"
  40. # Esto activa la imagen "layer2"
  41. #
  42. # Parallax2 <= Poner el ID del mapa q va a usar cielo
  43. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  44. Parallax2 = [0, # Mapas con el Cielo activado
  45. ]
  46. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  47. # Luces
  48. # Esta capa esta justo debajo de la capa cielo, puede moverse o estar quieta
  49. #
  50. #
  51. # Para activarla necesitamos una imagen en \Graphics\Parallaxes
  52. # con el nombre "X"_light
  53. # X es el numero de ID que lleva el mapa
  54. #
  55. # Ejemplo:
  56. # "\Graphics\Parallaxes\1_light"
  57. #
  58. #
  59. # Light <= Poner el ID del mapa q va a usar luces
  60. #
  61. #
  62. #:Flicker_Light
  63. #
  64. # 0 => No se mueve
  65. # 1 o mas => la luz se mueve, cualquier valor mayor a 1 queda raro el efecto
  66. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  67. Light = [0, #< Mapas con luces activadas
  68. ]
  69. Flicker_Light = 1 #< Movimiento de luces
  70.  
  71. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  72. # Sombras
  73. # Esta capa esta debajo del Cielo y las Luces, esta arriba del Suelo
  74. # puede moverse o estar quieta
  75. #
  76. # Para activarla necesitamos una imagen en \Graphics\Parallaxes
  77. # con el nombre "X"_shadow
  78. # X es el numero de ID que lleva el mapa
  79. #
  80. # Ejemplo:
  81. # "\Graphics\Parallaxes\1_shadow"
  82. #
  83. #
  84. # Shadow <= Poner el ID del mapa que va a usar las sombras
  85. #
  86. #
  87. #:Flicker_Shadow
  88. #
  89. # 0 => No se mueve
  90. # 1 o mas => la sombra se mueve, cualquier valor mayor a 1 queda raro el efecto
  91. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  92. Shadow = [0, #<=|Mapas con sombras activadas
  93. ]
  94. Flicker_Shadow = 0 #<= Movimiento de sombras
  95.  
  96. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  97. # Suelo
  98. # Esta capa esta debajo de los personajes y eventos y por encima de los Tiles
  99. #
  100. # Para activarla necesitamos una imagen en \Graphics\Parallaxes\
  101. # Con el nombre "X"_Ground
  102. # X es el numero de ID que lleva el mapa
  103. #
  104. # Ejemplo:
  105. # "\Graphics\Parallaxes\1_ground"
  106. #
  107. #
  108. # Ground <= Poner el ID del mapa que va a usar las sombras
  109. #
  110. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  111. Ground = [1, 3 #<=|Id of the map that will use the ground layer
  112.  
  113.  
  114. ]
  115. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  116. # Switches/Interruptores y Variables
  117. #
  118. # Interruptores
  119. #
  120. # Activa o desactiva las capas de parallax
  121. # si no lo vas a usar deja "nil"
  122. #
  123. # Variables
  124. # cambia la imagen de que va a usar
  125. #
  126. # Ejemplo:
  127. # La luz del mapa cuatro se llama: "4_light"
  128. #
  129. # pero si queres usar variables para ver que luz se activa:
  130. #
  131. # Valor de variable = "0 nombre" = "4_light"
  132. # Valor de variable = "1 nombre" = "4-1_light"
  133. # Valor de variable = "5 nombre" = "4-5_light
  134. #
  135. # Hay que agregar "-X" despues del ID del mapa
  136. # en el que "X" es el numero de variable
  137. #
  138. #
  139. #
  140. # Atencion
  141. #
  142. # Los switches/interruptores solo van a funcionar cuando este en on/off
  143. # Las variables necesitan cambiar de mapa primero
  144. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  145. SWITCH_SKY = nil
  146. SWITCH_LIGHT = nil
  147. SWITCH_SHADOW = nil
  148. SWITCH_GROUND = nil
  149.  
  150. VARIABLE_SKY = nil
  151. VARIABLE_LIGHT = nil
  152. VARIABLE_SHADOW = nil
  153. VARIABLE_GROUND = nil
  154. #==============================================================================
  155. # End of configuration
  156. #==============================================================================
  157. #==============================================================================
  158. # ** Spriteset_Map
  159. #------------------------------------------------------------------------------
  160. # This class brings together map screen sprites, tilemaps, etc. It's used
  161. # within the Scene_Map class.
  162. #==============================================================================
  163. end
  164. end
  165. class Spriteset_Map
  166. include GDS_Parallax::Parallax
  167. #=============================================================================
  168. # * alias method create_parallax
  169. #=============================================================================
  170. alias create_parallax_gds create_parallax
  171. def create_parallax
  172. create_parallax_gds
  173. create_parallaxes
  174. @do_it1 = true;@do_it2 = true;@do_it3 = true;@do_it4 = true
  175. end
  176. def create_parallaxes
  177. map = $game_map.map_id
  178. @maps = $game_map.map_id
  179. ;@check1 = true;@check2 = true;@check3 = true;@check4 = true
  180. @fixed_p = false;@create1 = false;@create2 = false;@create2 = false;@create3 = false;@create4 = false
  181. for i in FIXED_Parallax;@fixed_p = true if i == map;end
  182. for i in Parallax2;@create1 = true if i == map;end
  183. for i in Light;@create2 = true if i == map;end
  184. for i in Shadow;@create3 = true if i == map;end
  185. for i in Ground;@create4 = true if i == map;end
  186. @parallax1 = Plane.new(@viewport1) if @create1 == true
  187. @parallax1.z = 203 if @create1 == true;@check1 = false
  188. @parallax2 = Plane.new(@viewport1) if @create2 == true
  189. @parallax2.z = 202 if @create2 == true ;@check2 = false
  190. @parallax3 = Plane.new(@viewport1) if @create3 == true
  191. @parallax3.z = 201 if @create3 == true;@check3 = false
  192. @parallax4 = Plane.new(@viewport1) if @create4 == true
  193. @parallax4.z = 50 if @create4 == true ;@check4 = false
  194. on1= false
  195. on2= false
  196. on3= false
  197. on4= false
  198. end
  199. #=============================================================================
  200. # * new method create_and_dispose
  201. # * new method check_for_dispose
  202. #=============================================================================
  203. def create_and_dispose
  204. @parallax1.dispose if @on1 == true
  205. @parallax2.dispose if @on2 == true
  206. @parallax3.dispose if @on3 == true
  207. @parallax4.dispose if @on4 == true
  208. create_parallaxes
  209. p "done"
  210. end
  211. def check_for_dispose
  212. create_and_dispose if @maps != $game_map.map_id
  213. end
  214. #=============================================================================
  215. # * new method check_for_swicthes
  216. #=============================================================================
  217.  
  218.  
  219.  
  220.  
  221.  
  222. #=============================================================================
  223. # * alias method dispose_parallax
  224. #=============================================================================
  225. alias dispose_parallax_gds dispose_parallax
  226. def dispose_parallax
  227. @parallax1.dispose if @on1 == true
  228. @parallax2.dispose if @on2 == true
  229. @parallax3.dispose if @on3 == true
  230. @parallax4.dispose if @on4 == true
  231. dispose_parallax_gds
  232. end
  233. #=============================================================================
  234. # * overwrite method update_parallax
  235. #=============================================================================
  236. def update_parallax
  237. check_for_dispose
  238. @parallax1.visible= $game_switches[SWITCH_SKY] if SWITCH_SKY != nil
  239. @parallax2.visible= $game_switches[SWITCH_LIGHT] if SWITCH_LIGHT != nil
  240. @parallax3.visible= $game_switches[SWITCH_SHADOW] if SWITCH_SHADOW != nil
  241. @parallax4.visible= $game_switches[SWITCH_GROUND] if SWITCH_GROUND != nil
  242.  
  243. if @parallax_name != $game_map.parallax_name
  244. @parallax_name = $game_map.parallax_name
  245. @parallax.bitmap.dispose if @parallax.bitmap
  246. @parallax.bitmap = Cache.parallax(@parallax_name)
  247. Graphics.frame_reset
  248. end
  249. if @create1 == true and @check1 == false
  250. @parallax1.bitmap.dispose if @parallax1.bitmap
  251. sky = $game_map.map_id.to_s
  252. if VARIABLE_SKY != nil
  253. sky = $game_map.map_id.to_s+"-"+$game_variables[VARIABLE_SKY].to_s
  254. sky = $game_map.map_id.to_s if $game_variables[VARIABLE_SKY] == 0
  255. end
  256. @parallax1.bitmap = Cache.parallax(sky+"_layer2")
  257. Graphics.frame_reset
  258. @check1 = true;@on1 = true
  259. end
  260. if @create2 == true and @check2 == false
  261. @parallax2.bitmap.dispose if @parallax2.bitmap
  262. light = $game_map.map_id.to_s
  263. if VARIABLE_LIGHT != nil
  264. light = $game_map.map_id.to_s+"-"+$game_variables[VARIABLE_LIGHT].to_s
  265. light = $game_map.map_id.to_s if $game_variables[VARIABLE_LIGHT] == 0
  266. end
  267. @parallax2.bitmap = Cache.parallax(light+"_light")
  268. Graphics.frame_reset
  269. @check2 = true;@on2 = true
  270. end
  271. if @create3 == true and @check3 == false
  272. @parallax3.bitmap.dispose if @parallax3.bitmap
  273. shadow = $game_map.map_id.to_s
  274. if VARIABLE_SHADOW != nil
  275. shadow = $game_map.map_id.to_s+"-"+$game_variables[VARIABLE_SHADOW].to_s
  276. shadow = $game_map.map_id.to_s if $game_variables[VARIABLE_SHADOW] == 0
  277. end
  278. @parallax3.bitmap = Cache.parallax(shadow+"_shadow")
  279. Graphics.frame_reset
  280. @check3 = true;@on3 = true
  281. end
  282. if @create4 == true and @check4 == false
  283. @parallax4.bitmap.dispose if @parallax4.bitmap
  284. ground = $game_map.map_id.to_s
  285. if VARIABLE_GROUND != nil
  286. ground = $game_map.map_id.to_s+"-"+$game_variables[VARIABLE_GROUND].to_s
  287. ground = $game_map.map_id.to_s if $game_variables[VARIABLE_GROUND] == 0
  288. end
  289. @parallax4.bitmap = Cache.parallax(ground+"_ground")
  290. Graphics.frame_reset
  291. @check4 = true;@on4 = true
  292. end
  293. @parallax1.ox = $game_map.display_x * 32 if @create1 == true
  294. @parallax1.oy = $game_map.display_y * 32 if @create1 == true
  295.  
  296. @parallax2.ox = $game_map.display_x * 32 + rand(Flicker_Light) if @create2 == true
  297. @parallax2.oy = $game_map.display_y * 32 + rand(Flicker_Light) if @create2 == true
  298.  
  299. @parallax3.ox = $game_map.display_x * 32 + rand(Flicker_Shadow) if @create3 == true
  300. @parallax3.oy = $game_map.display_y * 32 + rand(Flicker_Shadow) if @create3 == true
  301.  
  302. @parallax4.ox = $game_map.display_x * 32 if @create4 == true
  303. @parallax4.oy = $game_map.display_y * 32 if @create4 == true
  304.  
  305. if @fixed_p == true
  306. @parallax.ox = $game_map.parallax_ox(@parallax.bitmap)
  307. @parallax.oy = $game_map.parallax_oy(@parallax.bitmap)
  308. else
  309. @parallax.ox = $game_map.display_x * 32
  310. @parallax.oy = $game_map.display_y * 32
  311. end
  312. end
  313. end
Advertisement
Add Comment
Please, Sign In to add comment