Class: Spriteset_Map

Inherits:
Object
  • Object
show all
Defined in:
Spriteset_Map.rb

Overview

** Spriteset_Map


This class brings together map screen sprites, tilemaps, etc. It's used

within the Scene_Map class.

Instance Method Summary (collapse)

Constructor Details

- (Spriteset_Map) initialize


  • Object Initialization




12
13
14
15
16
17
18
19
20
21
22
# File 'Spriteset_Map.rb', line 12

def initialize
  create_viewports
  create_tilemap
  create_parallax
  create_characters
  create_shadow
  create_weather
  create_pictures
  create_timer
  update
end

Instance Method Details

- (Object) create_characters


  • Create Character Sprite




61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'Spriteset_Map.rb', line 61

def create_characters
  @character_sprites = []
  $game_map.events.values.each do |event|
    @character_sprites.push(Sprite_Character.new(@viewport1, event))
  end
  $game_map.vehicles.each do |vehicle|
    @character_sprites.push(Sprite_Character.new(@viewport1, vehicle))
  end
  $game_player.followers.reverse_each do |follower|
    @character_sprites.push(Sprite_Character.new(@viewport1, follower))
  end
  @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
  @map_id = $game_map.map_id
end

- (Object) create_parallax


  • Create Parallax




54
55
56
57
# File 'Spriteset_Map.rb', line 54

def create_parallax
  @parallax = Plane.new(@viewport1)
  @parallax.z = -100
end

- (Object) create_pictures


  • Create Picture Sprite




94
95
96
# File 'Spriteset_Map.rb', line 94

def create_pictures
  @picture_sprites = []
end

- (Object) create_shadow


  • Create Airship Shadow Sprite




78
79
80
81
82
83
84
# File 'Spriteset_Map.rb', line 78

def create_shadow
  @shadow_sprite = Sprite.new(@viewport1)
  @shadow_sprite.bitmap = Cache.system("Shadow")
  @shadow_sprite.ox = @shadow_sprite.bitmap.width / 2
  @shadow_sprite.oy = @shadow_sprite.bitmap.height
  @shadow_sprite.z = 180
end

- (Object) create_tilemap


  • Create Tilemap




36
37
38
39
40
# File 'Spriteset_Map.rb', line 36

def create_tilemap
  @tilemap = Tilemap.new(@viewport1)
  @tilemap.map_data = $game_map.data
  load_tileset
end

- (Object) create_timer


  • Create Timer Sprite




100
101
102
# File 'Spriteset_Map.rb', line 100

def create_timer
  @timer_sprite = Sprite_Timer.new(@viewport2)
end

- (Object) create_viewports


  • Create Viewport




26
27
28
29
30
31
32
# File 'Spriteset_Map.rb', line 26

def create_viewports
  @viewport1 = Viewport.new
  @viewport2 = Viewport.new
  @viewport3 = Viewport.new
  @viewport2.z = 50
  @viewport3.z = 100
end

- (Object) create_weather


  • Create Weather




88
89
90
# File 'Spriteset_Map.rb', line 88

def create_weather
  @weather = Spriteset_Weather.new(@viewport2)
end

- (Object) dispose


  • Free




106
107
108
109
110
111
112
113
114
115
# File 'Spriteset_Map.rb', line 106

def dispose
  dispose_tilemap
  dispose_parallax
  dispose_characters
  dispose_shadow
  dispose_weather
  dispose_pictures
  dispose_timer
  dispose_viewports
end

- (Object) dispose_characters


  • Free Character Sprite




132
133
134
# File 'Spriteset_Map.rb', line 132

def dispose_characters
  @character_sprites.each {|sprite| sprite.dispose }
end

- (Object) dispose_parallax


  • Free Parallax




125
126
127
128
# File 'Spriteset_Map.rb', line 125

def dispose_parallax
  @parallax.bitmap.dispose if @parallax.bitmap
  @parallax.dispose
end

- (Object) dispose_pictures


  • Free Picture Sprite




150
151
152
# File 'Spriteset_Map.rb', line 150

def dispose_pictures
  @picture_sprites.compact.each {|sprite| sprite.dispose }
end

- (Object) dispose_shadow


  • Free Airship Shadow Sprite




138
139
140
# File 'Spriteset_Map.rb', line 138

def dispose_shadow
  @shadow_sprite.dispose
end

- (Object) dispose_tilemap


  • Free Tilemap




119
120
121
# File 'Spriteset_Map.rb', line 119

def dispose_tilemap
  @tilemap.dispose
end

- (Object) dispose_timer


  • Free Timer Sprite




156
157
158
# File 'Spriteset_Map.rb', line 156

def dispose_timer
  @timer_sprite.dispose
end

- (Object) dispose_viewports


  • Free Viewport




162
163
164
165
166
# File 'Spriteset_Map.rb', line 162

def dispose_viewports
  @viewport1.dispose
  @viewport2.dispose
  @viewport3.dispose
end

- (Object) dispose_weather


  • Free Weather




144
145
146
# File 'Spriteset_Map.rb', line 144

def dispose_weather
  @weather.dispose
end

- (Object) load_tileset


  • Load Tileset




44
45
46
47
48
49
50
# File 'Spriteset_Map.rb', line 44

def load_tileset
  @tileset = $game_map.tileset
  @tileset.tileset_names.each_with_index do |name, i|
    @tilemap.bitmaps[i] = Cache.tileset(name)
  end
  @tilemap.flags = @tileset.flags
end

- (Object) refresh_characters


  • Refresh Characters




170
171
172
173
# File 'Spriteset_Map.rb', line 170

def refresh_characters
  dispose_characters
  create_characters
end

- (Object) update


  • Frame Update




177
178
179
180
181
182
183
184
185
186
187
# File 'Spriteset_Map.rb', line 177

def update
  update_tileset
  update_tilemap
  update_parallax
  update_characters
  update_shadow
  update_weather
  update_pictures
  update_timer
  update_viewports
end

- (Object) update_characters


  • Update Character Sprite




222
223
224
225
# File 'Spriteset_Map.rb', line 222

def update_characters
  refresh_characters if @map_id != $game_map.map_id
  @character_sprites.each {|sprite| sprite.update }
end

- (Object) update_parallax


  • Update Parallax




209
210
211
212
213
214
215
216
217
218
# File 'Spriteset_Map.rb', line 209

def update_parallax
  if @parallax_name != $game_map.parallax_name
    @parallax_name = $game_map.parallax_name
    @parallax.bitmap.dispose if @parallax.bitmap
    @parallax.bitmap = Cache.parallax(@parallax_name)
    Graphics.frame_reset
  end
  @parallax.ox = $game_map.parallax_ox(@parallax.bitmap)
  @parallax.oy = $game_map.parallax_oy(@parallax.bitmap)
end

- (Object) update_pictures


*Update Picture Sprite




249
250
251
252
253
254
# File 'Spriteset_Map.rb', line 249

def update_pictures
  $game_map.screen.pictures.each do |pic|
    @picture_sprites[pic.number] ||= Sprite_Picture.new(@viewport2, pic)
    @picture_sprites[pic.number].update
  end
end

- (Object) update_shadow


  • Update Airship Shadow Sprite




229
230
231
232
233
234
235
# File 'Spriteset_Map.rb', line 229

def update_shadow
  airship = $game_map.airship
  @shadow_sprite.x = airship.screen_x
  @shadow_sprite.y = airship.screen_y + airship.altitude
  @shadow_sprite.opacity = airship.altitude * 8
  @shadow_sprite.update
end

- (Object) update_tilemap


  • Update Tilemap




200
201
202
203
204
205
# File 'Spriteset_Map.rb', line 200

def update_tilemap
  @tilemap.map_data = $game_map.data
  @tilemap.ox = $game_map.display_x * 32
  @tilemap.oy = $game_map.display_y * 32
  @tilemap.update
end

- (Object) update_tileset


  • Update Tileset




191
192
193
194
195
196
# File 'Spriteset_Map.rb', line 191

def update_tileset
  if @tileset != $game_map.tileset
    load_tileset
    refresh_characters
  end
end

- (Object) update_timer


  • Update Timer Sprite




258
259
260
# File 'Spriteset_Map.rb', line 258

def update_timer
  @timer_sprite.update
end

- (Object) update_viewports


  • Update Viewport




264
265
266
267
268
269
270
271
272
# File 'Spriteset_Map.rb', line 264

def update_viewports
  @viewport1.tone.set($game_map.screen.tone)
  @viewport1.ox = $game_map.screen.shake
  @viewport2.color.set($game_map.screen.flash_color)
  @viewport3.color.set(0, 0, 0, 255 - $game_map.screen.brightness)
  @viewport1.update
  @viewport2.update
  @viewport3.update
end

- (Object) update_weather


  • Update Weather




239
240
241
242
243
244
245
# File 'Spriteset_Map.rb', line 239

def update_weather
  @weather.type = $game_map.screen.weather_type
  @weather.power = $game_map.screen.weather_power
  @weather.ox = $game_map.display_x * 32
  @weather.oy = $game_map.display_y * 32
  @weather.update
end