Class: Spriteset_Battle

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

Overview

** Spriteset_Battle


This class brings together battle screen sprites. It's used within the

Scene_Battle class.

Instance Method Summary (collapse)

Constructor Details

- (Spriteset_Battle) initialize


  • Object Initialization




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

def initialize
  create_viewports
  create_battleback1
  create_battleback2
  create_enemies
  create_actors
  create_pictures
  create_timer
  update
end

Instance Method Details

- (Boolean) animation?


  • Determine if Animation is Being Displayed


Returns:

  • (Boolean)


380
381
382
# File 'Spriteset_Battle.rb', line 380

def animation?
  battler_sprites.any? {|sprite| sprite.animation? }
end

- (Object) autotile_type(z)


  • Get Type of Auto Tile at Player's Feet




205
206
207
# File 'Spriteset_Battle.rb', line 205

def autotile_type(z)
  $game_map.autotile_type($game_player.x, $game_player.y, z)
end

- (Object) battleback1_bitmap


  • Get Battle Background (Floor) Bitmap




53
54
55
56
57
58
59
# File 'Spriteset_Battle.rb', line 53

def battleback1_bitmap
  if battleback1_name
    Cache.battleback1(battleback1_name)
  else
    create_blurry_background_bitmap
  end
end

- (Object) battleback1_name


  • Get Filename of Battle Background (Floor)




83
84
85
86
87
88
89
90
91
# File 'Spriteset_Battle.rb', line 83

def battleback1_name
  if $BTEST
    $data_system.battleback1_name
  elsif $game_map.battleback1_name
    $game_map.battleback1_name
  elsif $game_map.overworld?
    overworld_battleback1_name
  end
end

- (Object) battleback2_bitmap


  • Get Battle Background (Wall) Bitmap




63
64
65
66
67
68
69
# File 'Spriteset_Battle.rb', line 63

def battleback2_bitmap
  if battleback2_name
    Cache.battleback2(battleback2_name)
  else
    Bitmap.new(1, 1)
  end
end

- (Object) battleback2_name


  • Get Filename of Battle Background (Wall)




95
96
97
98
99
100
101
102
103
# File 'Spriteset_Battle.rb', line 95

def battleback2_name
  if $BTEST
    $data_system.battleback2_name
  elsif $game_map.battleback2_name
    $game_map.battleback2_name
  elsif $game_map.overworld?
    overworld_battleback2_name
  end
end

- (Object) battler_sprites


  • Get Enemy and Actor Sprites




374
375
376
# File 'Spriteset_Battle.rb', line 374

def battler_sprites
  @enemy_sprites + @actor_sprites
end

- (Object) center_sprite(sprite)


  • Move Sprite to Screen Center




211
212
213
214
215
216
# File 'Spriteset_Battle.rb', line 211

def center_sprite(sprite)
  sprite.ox = sprite.bitmap.width / 2
  sprite.oy = sprite.bitmap.height / 2
  sprite.x = Graphics.width / 2
  sprite.y = Graphics.height / 2
end

- (Object) create_actors


  • Create Actor Sprite

    By default, the actor image is not displayed, but for convenience
    a dummy sprite is created for treating enemies and allies the same.



230
231
232
# File 'Spriteset_Battle.rb', line 230

def create_actors
  @actor_sprites = Array.new(4) { Sprite_Battler.new(@viewport1) }
end

- (Object) create_battleback1


  • Create Battle Background (Floor) Sprite




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

def create_battleback1
  @back1_sprite = Sprite.new(@viewport1)
  @back1_sprite.bitmap = battleback1_bitmap
  @back1_sprite.z = 0
  center_sprite(@back1_sprite)
end

- (Object) create_battleback2


  • Create Battle Background (Wall) Sprite




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

def create_battleback2
  @back2_sprite = Sprite.new(@viewport1)
  @back2_sprite.bitmap = battleback2_bitmap
  @back2_sprite.z = 1
  center_sprite(@back2_sprite)
end

- (Object) create_blurry_background_bitmap


  • Create Battle Background Bitmap from Processed Map Screen




73
74
75
76
77
78
79
# File 'Spriteset_Battle.rb', line 73

def create_blurry_background_bitmap
  source = SceneManager.background_bitmap
  bitmap = Bitmap.new(640, 480)
  bitmap.stretch_blt(bitmap.rect, source, source.rect)
  bitmap.radial_blur(120, 16)
  bitmap
end

- (Object) create_enemies


  • Create Enemy Sprite




220
221
222
223
224
# File 'Spriteset_Battle.rb', line 220

def create_enemies
  @enemy_sprites = $game_troop.members.reverse.collect do |enemy|
    Sprite_Battler.new(@viewport1, enemy)
  end
end

- (Object) create_pictures


  • Create Picture Sprite

    Create an empty array in the initial state and then add to it as
    necessary.



238
239
240
# File 'Spriteset_Battle.rb', line 238

def create_pictures
  @picture_sprites = []
end

- (Object) create_timer


  • Create Timer Sprite




244
245
246
# File 'Spriteset_Battle.rb', line 244

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

- (Object) create_viewports


  • Create Viewport




25
26
27
28
29
30
31
# File 'Spriteset_Battle.rb', line 25

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

- (Object) default_battleback1_name


  • Get Filename of Default Battle Background (Floor)




181
182
183
# File 'Spriteset_Battle.rb', line 181

def default_battleback1_name
  "Grassland"
end

- (Object) default_battleback2_name


  • Get Filename of Default Battle Background (Wall)




187
188
189
# File 'Spriteset_Battle.rb', line 187

def default_battleback2_name
  "Grassland"
end

- (Object) dispose


  • Free




250
251
252
253
254
255
256
257
258
# File 'Spriteset_Battle.rb', line 250

def dispose
  dispose_battleback1
  dispose_battleback2
  dispose_enemies
  dispose_actors
  dispose_pictures
  dispose_timer
  dispose_viewports
end

- (Object) dispose_actors


  • Free Actor Sprite




282
283
284
# File 'Spriteset_Battle.rb', line 282

def dispose_actors
  @actor_sprites.each {|sprite| sprite.dispose }
end

- (Object) dispose_battleback1


  • Free Battle Background (Floor) Sprite




262
263
264
265
# File 'Spriteset_Battle.rb', line 262

def dispose_battleback1
  @back1_sprite.bitmap.dispose
  @back1_sprite.dispose
end

- (Object) dispose_battleback2


  • Free Battle Background (Wall) Sprite




269
270
271
272
# File 'Spriteset_Battle.rb', line 269

def dispose_battleback2
  @back2_sprite.bitmap.dispose
  @back2_sprite.dispose
end

- (Object) dispose_enemies


  • Free Enemy Sprite




276
277
278
# File 'Spriteset_Battle.rb', line 276

def dispose_enemies
  @enemy_sprites.each {|sprite| sprite.dispose }
end

- (Object) dispose_pictures


  • Free Picture Sprite




288
289
290
# File 'Spriteset_Battle.rb', line 288

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

- (Object) dispose_timer


  • Free Timer Sprite




294
295
296
# File 'Spriteset_Battle.rb', line 294

def dispose_timer
  @timer_sprite.dispose
end

- (Object) dispose_viewports


  • Free Viewport




300
301
302
303
304
# File 'Spriteset_Battle.rb', line 300

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

- (Boolean) effect?


  • Determine if Effect Is Executing


Returns:

  • (Boolean)


386
387
388
# File 'Spriteset_Battle.rb', line 386

def effect?
  battler_sprites.any? {|sprite| sprite.effect? }
end

- (Object) normal_battleback1_name


  • Get Filename of Normal Battle Background (Floor)




119
120
121
122
123
# File 'Spriteset_Battle.rb', line 119

def normal_battleback1_name
  terrain_battleback1_name(autotile_type(1)) ||
  terrain_battleback1_name(autotile_type(0)) ||
  default_battleback1_name
end

- (Object) normal_battleback2_name


  • Get Filename of Normal Battle Background (Wall)




127
128
129
130
131
# File 'Spriteset_Battle.rb', line 127

def normal_battleback2_name
  terrain_battleback2_name(autotile_type(1)) ||
  terrain_battleback2_name(autotile_type(0)) ||
  default_battleback2_name
end

- (Object) overworld_battleback1_name


  • Get Filename of Field Battle Background (Floor)




107
108
109
# File 'Spriteset_Battle.rb', line 107

def overworld_battleback1_name
  $game_player.vehicle ? ship_battleback1_name : normal_battleback1_name
end

- (Object) overworld_battleback2_name


  • Get Filename of Field Battle Background (Wall)




113
114
115
# File 'Spriteset_Battle.rb', line 113

def overworld_battleback2_name
  $game_player.vehicle ? ship_battleback2_name : normal_battleback2_name
end

- (Object) ship_battleback1_name


  • Get Filename of Battle Background (Floor) When on Ship




193
194
195
# File 'Spriteset_Battle.rb', line 193

def ship_battleback1_name
  "Ship"
end

- (Object) ship_battleback2_name


  • Get Filename of Battle Background (Wall) When on Ship




199
200
201
# File 'Spriteset_Battle.rb', line 199

def ship_battleback2_name
  "Ship"
end

- (Object) terrain_battleback1_name(type)


  • Get Filename of Battle Background (Floor) Corresponding to Terrain




135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'Spriteset_Battle.rb', line 135

def terrain_battleback1_name(type)
  case type
  when 24,25        # Wasteland
    "Wasteland"
  when 26,27        # Dirt field
    "DirtField"
  when 32,33        # Desert
    "Desert"
  when 34           # Rocks
    "Lava1"
  when 35           # Rocks (lava)
    "Lava2"
  when 40,41        # Snowfield
    "Snowfield"
  when 42           # Clouds
    "Clouds"
  when 4,5          # Poisonous swamp
    "PoisonSwamp"
  end
end

- (Object) terrain_battleback2_name(type)


  • Get Filename of Battle Background (Wall) Corresponding to Terrain




158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'Spriteset_Battle.rb', line 158

def terrain_battleback2_name(type)
  case type
  when 20,21        # Forest
    "Forest1"
  when 22,30,38     # Low hill
    "Cliff"
  when 24,25,26,27  # Wasteland, dirt field
    "Wasteland"
  when 32,33        # Desert
    "Desert"
  when 34,35        #  Rocks
    "Lava"
  when 40,41        # Snowfield
    "Snowfield"
  when 42           # Clouds
    "Clouds"
  when 4,5          # Poisonous swamp
    "PoisonSwamp"
  end
end

- (Object) update


  • Frame Update




308
309
310
311
312
313
314
315
316
# File 'Spriteset_Battle.rb', line 308

def update
  update_battleback1
  update_battleback2
  update_enemies
  update_actors
  update_pictures
  update_timer
  update_viewports
end

- (Object) update_actors


  • Update Actor Sprite




338
339
340
341
342
343
# File 'Spriteset_Battle.rb', line 338

def update_actors
  @actor_sprites.each_with_index do |sprite, i|
    sprite.battler = $game_party.members[i]
    sprite.update
  end
end

- (Object) update_battleback1


  • Update Battle Background (Floor) Sprite




320
321
322
# File 'Spriteset_Battle.rb', line 320

def update_battleback1
  @back1_sprite.update
end

- (Object) update_battleback2


  • Update Battle Background (Wall) Sprite




326
327
328
# File 'Spriteset_Battle.rb', line 326

def update_battleback2
  @back2_sprite.update
end

- (Object) update_enemies


  • Update Enemy Sprite




332
333
334
# File 'Spriteset_Battle.rb', line 332

def update_enemies
  @enemy_sprites.each {|sprite| sprite.update }
end

- (Object) update_pictures


*Update Picture Sprite




347
348
349
350
351
352
# File 'Spriteset_Battle.rb', line 347

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

- (Object) update_timer


  • Update Timer Sprite




356
357
358
# File 'Spriteset_Battle.rb', line 356

def update_timer
  @timer_sprite.update
end

- (Object) update_viewports


  • Update Viewport




362
363
364
365
366
367
368
369
370
# File 'Spriteset_Battle.rb', line 362

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