1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
| #==============================================================================
# ** Sprite_Rain
# Par zou
# Version 1.0
#------------------------------------------------------------------------------
# This sprite is used to display animations at the water's surface during
# raining.
#==============================================================================
class Sprite_Rain < Sprite
TERRAIN_TAG = 1 # Choose the terrain tag
# This scipt need a picture named "wave" 20x18
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport)
super(viewport)
self.bitmap = Bitmap.new(640,480)
@waves = []
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
self.bitmap.clear
return if $game_screen.weather_max == 0 or $game_screen.weather_type == 3
x = $game_map.display_x/128
y = $game_map.display_y/128
for i in x...x+20
for j in y...y+15
if $game_map.terrain_tag(i,j) == TERRAIN_TAG
r = rand(1000)
if r < $game_screen.weather_max/2
x2 = 32*i + 12 + r/5
y2 = 32*j + 12 + r/5
down = $game_map.terrain_tag(i,j+1) != TERRAIN_TAG
up = $game_map.terrain_tag(i,j-1) != TERRAIN_TAG
next if up and down
y2 -= 16 if down
y2 += 4 if up
@waves.push(Wave.new(x2,y2))
end
end
end
end
for i in 0...@waves.size
@waves<i>.life += 1
life = @waves<i>.life
if life == 10
@waves<i> = nil
else
rect = Rect.new(@waves<i>.x-$game_map.display_x/4-life/2, @waves<i>.y-$game_map.display_y/4-life/2, 5+life,5+life)
self.bitmap.stretch_blt(rect, RPG::Cache.picture("wave"), Rect.new(0,0,20,18),255-25*life)
end
end
@waves.compact!
end
end
#==============================================================================
# ** Wave
#==============================================================================
class Wave
attr_accessor :life, :x, :y
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x,y)
@life = 0
@x = x
@y = y
end
end
module RPG
class Weather
def initialize(viewport = nil)
@type = 0
@max = 0
@ox = 0
@oy = 0
color1 = Color.new(200, 200, 255, 255)
color2 = Color.new(255, 255, 255, 128)
@rain_bitmap = Bitmap.new(2, 8)
@rain_bitmap.fill_rect(0, 4, 1, 4, color1)
@rain_bitmap.fill_rect(1, 0, 1, 4, color1)
@storm_bitmap = Bitmap.new(3, 12)
@storm_bitmap.fill_rect(2, 0, 1, 4, color2)
@storm_bitmap.fill_rect(1, 4, 1, 4, color1)
@storm_bitmap.fill_rect(0, 8, 1, 4, color2)
@snow_bitmap = Bitmap.new(4, 4)
@snow_bitmap.fill_rect(0, 1, 4, 2, color2)
@snow_bitmap.fill_rect(1, 0, 2, 4, color2)
@snow_bitmap.fill_rect(1, 1, 2, 2, color1)
@sprites = []
for i in 1..40
sprite = Sprite.new(viewport)
sprite.z = 1000
sprite.visible = false
sprite.opacity = 0
@sprites.push(sprite)
end
end
def update
return if @type == 0
for i in 1..@max
sprite = @sprites<i>
if sprite == nil
break
end
if @type == 1
sprite.x -= 2
sprite.y += 20
sprite.opacity -= 8
end
if @type == 2
sprite.x -= 5
sprite.y += 16
sprite.opacity -= 12
end
if @type == 3
sprite.x -= 1
sprite.y += 6
sprite.opacity -= 3
end
x = sprite.x - @ox
y = sprite.y - @oy
if sprite.opacity < 64 or x < -50 or x > 750 or y < -300 or y > 500
sprite.x = rand(800) - 50 + @ox
sprite.y = rand(800) - 200 + @oy
sprite.opacity = 255
end
end
end
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc.
# It's used within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Make viewports
@viewport1 = Viewport.new(0, 0, 640, 480)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport2.z = 200
@viewport3.z = 5000
# Make tilemap
@tilemap = Tilemap.new(@viewport1)
@tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
for i in 0..6
autotile_name = $game_map.autotile_names<i>
@tilemap.autotiles<i> = RPG::Cache.autotile(autotile_name)
end
@tilemap.map_data = $game_map.data
@tilemap.priorities = $game_map.priorities
# Make panorama plane
@panorama = Plane.new(@viewport1)
@panorama.z = -1000
# Make fog plane
@fog = Plane.new(@viewport1)
@fog.z = 3000
# Make rain bitmap
@rain = Sprite_Rain.new(@viewport1)
@rain.z = 0
# Make character sprites
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events<i>)
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
# Make weather
@weather = RPG::Weather.new(@viewport1)
# Make picture sprites
@picture_sprites = []
for i in 1..50
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_screen.pictures<i>))
end
# Make timer sprite
@timer_sprite = Sprite_Timer.new
# Frame update
update
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
# Dispose of tilemap
@tilemap.tileset.dispose
for i in 0..6
@tilemap.autotiles<i>.dispose
end
@tilemap.dispose
# Dispose of panorama plane
@panorama.dispose
# Dispose of fog plane
@fog.dispose
# Dispose of rain bitmap
@rain.dispose
# Dispose of character sprites
for sprite in @character_sprites
sprite.dispose
end
# Dispose of weather
@weather.dispose
# Dispose of picture sprites
for sprite in @picture_sprites
sprite.dispose
end
# Dispose of timer sprite
@timer_sprite.dispose
# Dispose of viewports
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# If panorama is different from current one
if @panorama_name != $game_map.panorama_name or
@panorama_hue != $game_map.panorama_hue
@panorama_name = $game_map.panorama_name
@panorama_hue = $game_map.panorama_hue
if @panorama.bitmap != nil
@panorama.bitmap.dispose
@panorama.bitmap = nil
end
if @panorama_name != ""
@panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
end
Graphics.frame_reset
end
# If fog is different than current fog
if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
@fog_name = $game_map.fog_name
@fog_hue = $game_map.fog_hue
if @fog.bitmap != nil
@fog.bitmap.dispose
@fog.bitmap = nil
end
if @fog_name != ""
@fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
end
Graphics.frame_reset
end
# Update rain
@rain.update
# Update tilemap
@tilemap.ox = $game_map.display_x / 4
@tilemap.oy = $game_map.display_y / 4
@tilemap.update
# Update panorama plane
@panorama.ox = $game_map.display_x / 8
@panorama.oy = $game_map.display_y / 8
# Update fog plane
@fog.zoom_x = $game_map.fog_zoom / 100.0
@fog.zoom_y = $game_map.fog_zoom / 100.0
@fog.opacity = $game_map.fog_opacity
@fog.blend_type = $game_map.fog_blend_type
@fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
@fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
@fog.tone = $game_map.fog_tone
# Update character sprites
for sprite in @character_sprites
sprite.update
end
# Update weather graphic
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.ox = $game_map.display_x / 4
@weather.oy = $game_map.display_y / 4
@weather.update
# Update picture sprites
for sprite in @picture_sprites
sprite.update
end
# Update timer sprite
@timer_sprite.update
# Set screen color tone and shake position
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
# Set screen flash color
@viewport3.color = $game_screen.flash_color
# Update viewports
@viewport1.update
@viewport3.update
end
end
|