openrgss 0.1.1-x86-mingw32 → 0.1.2-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,51 @@
1
+ # The multidimensional array class. Each element is an integer of 2 signed bytes ranging from -32,768 to 32,767.
2
+ #
3
+ # Ruby's Array class does not run efficiently when handling large amounts of data, hence the inclusion of this class.
4
+
5
+ class Table
6
+ attr_reader :xsize, :ysize, :zsize
7
+
8
+ # Creates a Table object. Specifies the size of each dimension in the multidimensional array. 1-, 2-, and 3-dimensional arrays are possible. Arrays with no parameters are also permitted.
9
+
10
+ def initialize(xsize, ysize=1, zsize=1)
11
+ @xsize = xsize
12
+ @ysize = ysize
13
+ @zsize = zsize
14
+ @data = Array.new(@xsize*@ysize*@zsize, 0)
15
+ end
16
+
17
+ # Changes the size of the array. All data from before the size change is retained.
18
+
19
+ def resize(xsize, ysize=1, zsize=1)
20
+
21
+ end
22
+
23
+ # :call-seq:
24
+ # self[x]
25
+ # self[x, y]
26
+ # self[x, y, z]
27
+ #
28
+ # Accesses the array's elements. Pulls the same number of arguments as there are dimensions in the created array. Returns nil if the specified element does not exist.
29
+
30
+ def [](x, y=0, z=0)
31
+ return nil if x >= @xsize or y >= @ysize
32
+ @data[x + y * @xsize + z * @xsize * @ysize]
33
+ end
34
+
35
+ def []=(x, y=0, z=0, v) #:nodoc:
36
+ @data[x + y * @xsize + z * @xsize * @ysize]=v
37
+ end
38
+
39
+
40
+
41
+ def self._load(s) #:nodoc:
42
+ Table.new(1).instance_eval {
43
+ @size, @xsize, @ysize, @zsize, xx, *@data = s.unpack('LLLLLS*')
44
+ self
45
+ }
46
+ end
47
+
48
+ def _dump(d = 0) #:nodoc:
49
+ [@size, @xsize, @ysize, @zsize, @xsize*@ysize*@zsize, *@data].pack('LLLLLS*')
50
+ end
51
+ end
@@ -0,0 +1,686 @@
1
+ #==============================================================================
2
+ # ** Tilemap
3
+ #------------------------------------------------------------------------------
4
+ # This class draws the map according to the data given.
5
+ #------------------------------------------------------------------------------
6
+ # Version 1.05
7
+ # Author Ramiro
8
+ #------------------------------------------------------------------------------
9
+ # Changelog:
10
+ # 11/28/11 (1.00): First Version.
11
+ # 11/29/11 (1.03): Waterfall Tiles, A3, A4 Fixed.
12
+ # 11/29/11 (1.05): Added Shadows, default configurations.
13
+ # http://www.rpgmakervx.net/index.php?showtopic=51646
14
+ #==============================================================================
15
+ class Tilemap
16
+ #--------------------------------------------------------------------------
17
+ # * Default Configurations
18
+ #--------------------------------------------------------------------------
19
+ DEFAULT_FRAME_INTERVAL = 20 # Sets the interval of the animated tiles
20
+ DEFAULT_FLASH_INTERVAL = 15 # Sets the interval of flash data
21
+ DEFAULT_SHADOW_VISIBLE = true # Sets the visibility by default of shadows
22
+
23
+ #--------------------------------------------------------------------------
24
+ # * Constants
25
+ #--------------------------------------------------------------------------
26
+ # The parts of the autotiles
27
+ AUTOTILE_PARTS = [[18,17,14,13], [ 2,14,17,18], [13, 3,17,18], [ 2, 3,17,18],
28
+ [13,14,17, 7], [ 2,14,17, 7], [13, 3,17, 7], [ 2, 3,17, 7],
29
+ [13,14, 6,18], [ 2,14, 6,18], [13, 3, 6,18], [ 2, 3, 6,18],
30
+ [13,14, 6, 7], [ 2,14, 6, 7], [13, 3, 6, 7], [ 2, 3, 6, 7],
31
+ [16,17,12,13], [16, 3,12,13], [16,17,12, 7], [12, 3,16, 7],
32
+ [10, 9,14,13], [10, 9,14, 7], [10, 9, 6,13], [10, 9, 6, 7],
33
+ [18,19,14,15], [18,19, 6,15], [ 2,19,14,15], [ 2,19, 6,15],
34
+ [18,17,22,21], [ 2,17,22,21], [18, 3,22,21], [ 2, 3,21,22],
35
+ [16,19,12,15], [10, 9,22,21], [ 8, 9,12,13], [ 8, 9,12, 7],
36
+ [10,11,14,15], [10,11, 6,15], [18,19,22,23], [ 2,19,22,23],
37
+ [16,17,20,21], [16, 3,20,21], [ 8,11,12,15], [ 8, 9,20,21],
38
+ [16,19,20,23], [10,11,22,23], [ 8,11,20,23], [ 0, 1, 4, 5]]
39
+ WATERFALL_PIECES = [[ 2, 1, 5, 6], [ 0, 1, 4, 5], [ 2, 3, 6, 7]]
40
+ WALL_PIECES = [[10, 9, 6, 5], [ 8, 9, 4, 5], [ 2, 1, 6, 5], [ 0, 1, 4, 5],
41
+ [10,11, 6, 7], [ 8,11, 4, 7], [ 2, 3, 6, 7], [ 0, 3, 4, 7],
42
+ [10, 9,14,13], [ 8, 9,12,13], [ 2, 1,14,13], [ 0, 1,12,13],
43
+ [10,11,14,15], [10,11, 6, 7], [ 2, 3,14,15], [ 0, 3,12,15]]
44
+
45
+
46
+
47
+
48
+
49
+ # Passabilityes of the passages data
50
+ PASSABLE_TILE = 0x00
51
+ IMPASSABLE_TILE = 0x01
52
+ OVER_TILE = 0x10
53
+ #--------------------------------------------------------------------------
54
+ # * Class Variables
55
+ #--------------------------------------------------------------------------
56
+ @@autotile_list = [{}, {}, {}]
57
+ #--------------------------------------------------------------------------
58
+ # * Public Instance Variables
59
+ #--------------------------------------------------------------------------
60
+ attr_reader :viewport # The viewport of the map
61
+ attr_reader :visible # The visibility of the map
62
+ attr_reader :map_data # The data of the map
63
+ attr_accessor :bitmaps # The bitmap array of the tileset
64
+ attr_accessor :ox # The ox of the tilemap
65
+ attr_accessor :oy # The oy of the tilemap
66
+ attr_accessor :passages # The passability of the map
67
+ attr_accessor :frame_interval # The frame interval of water animation
68
+ attr_accessor :flash_interval # The flash interval of flash_data
69
+ attr_accessor :shadow_visible # determines if the auto shadows are visible
70
+ attr_accessor :flags
71
+ #--------------------------------------------------------------------------
72
+ # * Object Initialization
73
+ # viewport : the viewport of the tilemap
74
+ #--------------------------------------------------------------------------
75
+ def initialize(viewport=nil)
76
+ @bitmaps = []
77
+ @layers = [Plane.new(viewport), Plane.new(viewport), Plane.new(viewport),
78
+ Plane.new(viewport), Plane.new(viewport), Plane.new(viewport)]
79
+ @viewport = viewport
80
+ @ox = 0
81
+ @oy = 0
82
+ @layers[0].z = 0 # soil
83
+ @layers[1].z = 50 # soil objects
84
+ @layers[2].z = 100 # upper layer
85
+ @layers[3].z = 250 # upper layer 2
86
+ @layers[4].z = 300 # flash layer
87
+ @layers[5].z = 75 # shadow layer
88
+ @need_refresh = false
89
+ @map_data = nil
90
+ @passages = nil
91
+ @flash_data = nil
92
+ @visible = true
93
+ @disposed = false
94
+ @layer_bitmaps = []
95
+ @frame = 0
96
+ @frame_count = 0
97
+ @frame_interval = DEFAULT_FRAME_INTERVAL
98
+ @flash_count = 0
99
+ @flash_interval = DEFAULT_FLASH_INTERVAL
100
+ @flash_goal = 0
101
+ @shadow_visible = DEFAULT_SHADOW_VISIBLE
102
+ self.visible = true
103
+ end
104
+ #--------------------------------------------------------------------------
105
+ # * Checks if a tile is a wall
106
+ #--------------------------------------------------------------------------
107
+ def is_wall?(data)
108
+ return true if data.between?(2288, 2335)
109
+ return true if data.between?(2384, 2431)
110
+ return true if data.between?(2480, 2527)
111
+ return true if data.between?(2576, 2623)
112
+ return true if data.between?(2672, 2719)
113
+ return true if data.between?(2768, 2815)
114
+ return true if data.between?(4736, 5119)
115
+ return true if data.between?(5504, 5887)
116
+ return true if data.between?(6272, 6655)
117
+ return true if data.between?(7040, 7423)
118
+ return true if data > 7807
119
+ false
120
+ end
121
+ #--------------------------------------------------------------------------
122
+ # * Checks if a tile is roof
123
+ #--------------------------------------------------------------------------
124
+ def is_roof?(data)
125
+ return true if data.between?(4352, 4735)
126
+ return true if data.between?(5120, 5503)
127
+ return true if data.between?(5888, 6271)
128
+ return true if data.between?(6656, 7039)
129
+ return true if data.between?(7424, 7807)
130
+ false
131
+ end
132
+ #--------------------------------------------------------------------------
133
+ # * Checks if a tile is soil
134
+ #--------------------------------------------------------------------------
135
+ def is_soil?(data)
136
+ return true if data.between?(2816, 4351) && !is_table?(data)
137
+ return true if data > 1663 && !is_stair?(data)
138
+ false
139
+ end
140
+ #--------------------------------------------------------------------------
141
+ # * Checks if a tile is a stair
142
+ #--------------------------------------------------------------------------
143
+ def is_stair?(data)
144
+ return true if data.between?(1541, 1542)
145
+ return true if data.between?(1549, 1550)
146
+ return true if data.between?(1600, 1615)
147
+ false
148
+ end
149
+ #--------------------------------------------------------------------------
150
+ # * Checks if a tile is a table
151
+ #--------------------------------------------------------------------------
152
+ def is_table?(data)
153
+ return true if data.between?(3152, 3199)
154
+ return true if data.between?(3536, 3583)
155
+ return true if data.between?(3920, 3967)
156
+ return true if data.between?(4304, 4351)
157
+ false
158
+ end
159
+
160
+ def projects_shadow?(data)
161
+ return true if is_wall?(data)
162
+ return true if is_roof?(data)
163
+ false
164
+ end
165
+
166
+ #--------------------------------------------------------------------------
167
+ # * Gets the tile by the id
168
+ #--------------------------------------------------------------------------
169
+ def get_bitmap(id, frame=0)
170
+ return @@autotile_list[frame][id] if @@autotile_list[frame][id]
171
+ bmp = Bitmap.new(32, 32)
172
+ if id < 1024 # B-E
173
+ sub_id = id % 256
174
+ case id / 256
175
+ when 0 # B
176
+ tilemap = @bitmaps[5]
177
+ when 1 # C
178
+ tilemap = @bitmaps[6]
179
+ when 2 # D
180
+ tilemap = @bitmaps[7]
181
+ else # E
182
+ tilemap = @bitmaps[8]
183
+ end
184
+ if sub_id < 128
185
+ bmp.blt(0,0, tilemap, Rect.new((sub_id % 8) * 32, (sub_id / 8) * 32, 32, 32))
186
+ else
187
+ sub_id -= 128
188
+ bmp.blt(0,0, tilemap, Rect.new((sub_id % 8) * 32 + 256, (sub_id / 8) * 32, 32, 32))
189
+ end
190
+ elsif id < 1664 # A5
191
+ tilemap = @bitmaps[4]
192
+ sub_id = id - 1536
193
+ bmp.blt(0,0, tilemap, Rect.new((sub_id % 8) * 32, (sub_id / 8) * 32, 32, 32))
194
+ elsif id < 2816 # A1
195
+ sub_id = id - 2048
196
+ autotile = sub_id / 48
197
+ auto_id = sub_id % 48
198
+ tilemap = @bitmaps[0]
199
+ case autotile
200
+ when 0 # sea water
201
+ case frame
202
+ when 0
203
+ sx = 0
204
+ sy = 0
205
+ when 1
206
+ sx = 64
207
+ sy = 0
208
+ else
209
+ sx = 128
210
+ sy = 0
211
+ end
212
+ when 1 # sea deep water
213
+ case frame
214
+ when 0
215
+ sx = 0
216
+ sy = 96
217
+ when 1
218
+ sx = 64
219
+ sy = 96
220
+ else
221
+ sx = 128
222
+ sy = 96
223
+ end
224
+
225
+ when 2 # sea rocks
226
+ sx = 192
227
+ sy = 0
228
+ when 3 # ice rocks
229
+ sx = 192
230
+ sy = 96
231
+ when 4 # shallow water
232
+ case frame
233
+ when 0
234
+ sx = 256
235
+ sy = 0
236
+ when 1
237
+ sx = 320
238
+ sy = 0
239
+ else
240
+ sx = 384
241
+ sy = 0
242
+ end
243
+ when 5 # shallow waterfall
244
+ case frame
245
+ when 0
246
+ sx = 448
247
+ sy = 0
248
+ when 1
249
+ sx = 448
250
+ sy = 32
251
+ else
252
+ sx = 448
253
+ sy = 64
254
+ end
255
+ when 6 # town water
256
+ case frame
257
+ when 0
258
+ sx = 256
259
+ sy = 96
260
+ when 1
261
+ sx = 320
262
+ sy = 96
263
+ else
264
+ sx = 384
265
+ sy = 96
266
+ end
267
+ when 7 # town waterfall
268
+ case frame
269
+ when 0
270
+ sx = 448
271
+ sy = 96
272
+ when 1
273
+ sx = 448
274
+ sy = 128
275
+ else
276
+ sx = 448
277
+ sy = 160
278
+ end
279
+ when 8 # cave water
280
+ case frame
281
+ when 0
282
+ sx = 0
283
+ sy = 192
284
+ when 1
285
+ sx = 64
286
+ sy = 192
287
+ else
288
+ sx = 128
289
+ sy = 192
290
+ end
291
+ when 9 # cave waterfall
292
+ case frame
293
+ when 0
294
+ sx = 192
295
+ sy = 192
296
+ when 1
297
+ sx = 192
298
+ sy = 224
299
+ else
300
+ sx = 192
301
+ sy = 256
302
+ end
303
+ when 10 # temple water
304
+ case frame
305
+ when 0
306
+ sx = 0
307
+ sy = 288
308
+ when 1
309
+ sx = 64
310
+ sy = 288
311
+ else
312
+ sx = 128
313
+ sy = 288
314
+ end
315
+
316
+ when 11 # temple waterfall
317
+ case frame
318
+ when 0
319
+ sx = 192
320
+ sy = 288
321
+ when 1
322
+ sx = 192
323
+ sy = 320
324
+ else
325
+ sx = 192
326
+ sy = 352
327
+ end
328
+ when 12 # deep water
329
+ case frame
330
+ when 0
331
+ sx = 256
332
+ sy = 192
333
+ when 1
334
+ sx = 320
335
+ sy = 192
336
+ else
337
+ sx = 384
338
+ sy = 192
339
+ end
340
+ when 13 # deep waterfall
341
+ case frame
342
+ when 0
343
+ sx = 448
344
+ sy = 192
345
+ when 1
346
+ sx = 448
347
+ sy = 224
348
+ else
349
+ sx = 448
350
+ sy = 256
351
+ end
352
+ when 14 # magma water
353
+ case frame
354
+ when 0
355
+ sx = 256
356
+ sy = 288
357
+ when 1
358
+ sx = 320
359
+ sy = 288
360
+ else
361
+ sx = 384
362
+ sy = 288
363
+ end
364
+
365
+ else # magma waterfall
366
+ case frame
367
+ when 0
368
+ sx = 448
369
+ sy = 288
370
+ when 1
371
+ sx = 448
372
+ sy = 320
373
+ else
374
+ sx = 448
375
+ sy = 352
376
+ end
377
+ end
378
+
379
+ if is_wall?(id)
380
+ rects = WATERFALL_PIECES[auto_id]
381
+ else
382
+ rects = AUTOTILE_PARTS[auto_id]
383
+ end
384
+ rect = Rect.new(0,0,16,16)
385
+ for i in 0...4
386
+ rect.x = (rects[i] % 4) * 16 + sx
387
+ rect.y = (rects[i] / 4) * 16 + sy
388
+ bmp.blt((i % 2) * 16,(i / 2) * 16,tilemap,rect)
389
+ end
390
+ elsif id < 4352 # A2
391
+ sub_id = id - 2816
392
+ autotile = sub_id / 48
393
+ auto_id = sub_id % 48
394
+ tilemap = @bitmaps[1]
395
+ sx = (autotile % 8) * 64
396
+ sy = (autotile / 8) * 96
397
+ rects = AUTOTILE_PARTS[auto_id]
398
+ rect = Rect.new(0,0,16,16)
399
+ for i in 0...4
400
+ rect.x = (rects[i] % 4) * 16 + sx
401
+ rect.y = (rects[i] / 4) * 16 + sy
402
+ bmp.blt((i % 2) * 16,(i / 2) * 16,tilemap,rect)
403
+ end
404
+
405
+ elsif id < 5888 # A3
406
+ sub_id = id - 4352
407
+ autotile = sub_id / 48
408
+ auto_id = sub_id % 48
409
+ tilemap = @bitmaps[2]
410
+ sx = (autotile % 8) * 64
411
+ sy = (autotile / 8) * 64
412
+ rects = WALL_PIECES[auto_id]
413
+ rect = Rect.new(0,0,16,16)
414
+ for i in 0...4
415
+ rect.x = (rects[i] % 4) * 16 + sx
416
+ rect.y = (rects[i] / 4) * 16 + sy
417
+ bmp.blt((i % 2) * 16,(i / 2) * 16,tilemap,rect)
418
+ end
419
+ else # A4
420
+ sub_id = id - 5888
421
+ autotile = sub_id / 48
422
+ auto_id = sub_id % 48
423
+ tilemap = @bitmaps[3]
424
+ sx = (autotile % 8) * 64
425
+ case autotile / 8
426
+ when 0
427
+ sy = 0
428
+ when 1
429
+ sy = 96
430
+ when 2
431
+ sy = 160
432
+ when 3
433
+ sy = 256
434
+ when 4
435
+ sy = 320
436
+ else
437
+ sy = 416
438
+ end
439
+ if is_wall?(id)
440
+ rects = WALL_PIECES[auto_id]
441
+ else
442
+ rects = AUTOTILE_PARTS[auto_id]
443
+ end
444
+
445
+ rect = Rect.new(0,0,16,16)
446
+ for i in 0...rects.size
447
+ rect.x = (rects[i] % 4) * 16 + sx
448
+ rect.y = (rects[i] / 4) * 16 + sy
449
+ bmp.blt((i % 2) * 16,(i / 2) * 16,tilemap,rect)
450
+ end
451
+
452
+ end
453
+ @@autotile_list[frame][id] = bmp
454
+ @@autotile_list[frame][id]
455
+ end
456
+ #--------------------------------------------------------------------------
457
+ # * Checks if the tilemap is disposed
458
+ #--------------------------------------------------------------------------
459
+ def disposed?
460
+ @disposed
461
+ end
462
+ #--------------------------------------------------------------------------
463
+ # * Sets the viewport of the object
464
+ #--------------------------------------------------------------------------
465
+ def viewport=(value)
466
+ @layers.each do |i|
467
+ i.viewport = value
468
+ end
469
+ @viewport = value
470
+ end
471
+ #--------------------------------------------------------------------------
472
+ # * Sets if a map is visible
473
+ #--------------------------------------------------------------------------
474
+ def visible=(value)
475
+ @layers.each do |i|
476
+ i.visible = value
477
+ end
478
+ end
479
+ #--------------------------------------------------------------------------
480
+ # * Gets the flash data
481
+ #--------------------------------------------------------------------------
482
+ def flash_data
483
+ @need_flash_refresh = true
484
+ @flash_data
485
+ end
486
+ #--------------------------------------------------------------------------
487
+ # * Sets the flash data
488
+ #--------------------------------------------------------------------------
489
+ def flash_data=(value)
490
+ @flash_data = value
491
+ @need_flash_refresh = true
492
+ end
493
+ #--------------------------------------------------------------------------
494
+ # * Frame update
495
+ #--------------------------------------------------------------------------
496
+ def update
497
+ if @need_refresh
498
+ refresh
499
+ @need_refresh=false
500
+ end
501
+ update_animation
502
+ correct_position
503
+ @layers[5].visible = @shadow_visible
504
+ update_flash
505
+ end
506
+ #--------------------------------------------------------------------------
507
+ # * Correct the position of the map
508
+ #--------------------------------------------------------------------------
509
+ def correct_position
510
+ @layers.each do |i|
511
+ i.ox = @ox
512
+ i.oy = @oy
513
+ end
514
+ end
515
+ #--------------------------------------------------------------------------
516
+ # * Updates the animation of animated tiles
517
+ #--------------------------------------------------------------------------
518
+ def update_animation
519
+ @frame_count = (@frame_count + 1) % @frame_interval
520
+ if @frame_count == 0
521
+ @frame = (@frame + 1) % 3
522
+ if @frame > 2
523
+ @layers[0].bitmap = @layer_bitmaps[1]#.clone
524
+ else
525
+ @layers[0].bitmap = @layer_bitmaps[@frame]#.clone
526
+ end
527
+ end
528
+ end
529
+ #--------------------------------------------------------------------------
530
+ # * Updates the flash of the map
531
+ #--------------------------------------------------------------------------
532
+ def update_flash
533
+ if @need_flash_refresh
534
+ @need_flash_refresh = false
535
+ refresh_flash
536
+ end
537
+ if @flash_count > 0
538
+ @layers[4].opacity = (@layers[4].opacity * (@flash_count - 1) + @flash_goal ) / @flash_count
539
+ @flash_count -= 1
540
+ else
541
+ @flash_count = @flash_interval
542
+ @flash_goal = @flash_goal == 128 ? 0 : 128
543
+ end
544
+ end
545
+ #--------------------------------------------------------------------------
546
+ # * Sets the map data
547
+ #--------------------------------------------------------------------------
548
+ def map_data=(value)
549
+ return if @map_data == value
550
+ @map_data = value
551
+ if @map_data
552
+ @flash_data = Table.new(@map_data.xsize, @map_data.ysize)
553
+ @need_refresh=true
554
+ end
555
+ end
556
+ #--------------------------------------------------------------------------
557
+ # * Sets the passages
558
+ #--------------------------------------------------------------------------
559
+ def passages=(value)
560
+ @passages = value
561
+ refresh if @passages
562
+ end
563
+ #--------------------------------------------------------------------------
564
+ # * Dispose the Tilemap
565
+ #--------------------------------------------------------------------------
566
+ def dispose
567
+ @layers.each do |i|
568
+ i.bitmap.dispose if i.bitmap
569
+ i.dispose
570
+ end
571
+ @layer_bitmaps.each do |i|
572
+ i.dispose if i
573
+ end
574
+ @disposed = true
575
+ end
576
+ #--------------------------------------------------------------------------
577
+ # * Refresh the Tilemap
578
+ #--------------------------------------------------------------------------
579
+ def refresh
580
+ @frame_count = 0
581
+ return if !@map_data
582
+ # return if !@passages
583
+ @need_refresh = false
584
+ @layer_bitmaps.each do |i|
585
+ i.dispose
586
+ end
587
+ # !!!DEBUG
588
+ print "Refresh the Tilemap\n"
589
+ @layer_bitmaps.clear
590
+ rect = Rect.new(0,0,32,32)
591
+ for l in 0...3
592
+ bitmap = Bitmap.new(@map_data.xsize * 32, @map_data.ysize * 32)
593
+ for i in 0...@map_data.xsize
594
+ for j in 0...@map_data.ysize
595
+ x = i * 32
596
+ y = j * 32
597
+ bitmap.blt(x, y, get_bitmap(@map_data[i, j, 0], l), rect)
598
+ end
599
+ end
600
+ @layer_bitmaps.push(bitmap)
601
+ end
602
+
603
+ bitmap = Bitmap.new(@map_data.xsize * 32, @map_data.ysize * 32)
604
+ for i in 0...@map_data.xsize
605
+ for j in 0...@map_data.ysize
606
+ x = i * 32
607
+ y = j * 32
608
+ bitmap.blt(x, y, get_bitmap(@map_data[i, j, 1]), rect)
609
+ end
610
+ end
611
+ @layer_bitmaps.push(bitmap)
612
+
613
+ bitmap = Bitmap.new(@map_data.xsize * 32, @map_data.ysize * 32)
614
+ for i in 0...@map_data.xsize
615
+ for j in 0...@map_data.ysize
616
+ x = i * 32
617
+ y = j * 32
618
+ #if OVER_TILE #& @passages[@map_data[i, j, 2]] != OVER_TILE
619
+ bitmap.blt(x, y, get_bitmap(@map_data[i, j, 2]), rect)
620
+ #end
621
+ end
622
+ end
623
+ @layer_bitmaps.push(bitmap)
624
+ bitmap = Bitmap.new(@map_data.xsize * 32, @map_data.ysize * 32)
625
+ for i in 0...@map_data.xsize
626
+ for j in 0...@map_data.ysize
627
+ x = i * 32
628
+ y = j * 32
629
+ #if OVER_TILE #& @passages[@map_data[i, j, 2]] == OVER_TILE
630
+ bitmap.blt(x, y, get_bitmap(@map_data[i, j, 2]), rect)
631
+ #end
632
+ end
633
+ end
634
+
635
+ @layer_bitmaps.push(bitmap)
636
+ @layers[0].bitmap = @layer_bitmaps[@frame]
637
+ @layers[1].bitmap = @layer_bitmaps[3]
638
+ @layers[2].bitmap = @layer_bitmaps[4]
639
+ @layers[3].bitmap = @layer_bitmaps[5]
640
+ create_shadow_bitmap
641
+
642
+ end
643
+ #--------------------------------------------------------------------------
644
+ # * Creates the shadow bitmap
645
+ #--------------------------------------------------------------------------
646
+ def create_shadow_bitmap
647
+ @layers[5].bitmap.dispose if @layers[5].bitmap
648
+ bmp = Bitmap.new(@map_data.xsize * 32, @map_data.ysize * 32)
649
+ @layers[5].bitmap = bmp
650
+ for i in 1...@map_data.xsize
651
+ for j in 0...@map_data.ysize
652
+ if !projects_shadow?(@map_data[i,j,0])
653
+ if projects_shadow?(@map_data[i-1,j,0]) && (j == 0 || projects_shadow?(@map_data[i-1,j-1,0]))
654
+ bmp.fill_rect(i * 32, j * 32, 16, 32, Color.new(0,0,0,128))
655
+ end
656
+ end
657
+ end
658
+ end
659
+ end
660
+
661
+ #--------------------------------------------------------------------------
662
+ # * Refresh the Flash
663
+ #--------------------------------------------------------------------------
664
+ def refresh_flash
665
+ @flash_count = 0
666
+ @layers[4].bitmap.dispose if @layers[4].bitmap
667
+ return if !@flash_data
668
+ bmp = Bitmap.new(@flash_data.xsize * 32, @flash_data.ysize * 32)
669
+ @layers[4].bitmap = bmp
670
+ for i in 0...@flash_data.xsize
671
+ for j in 0...@flash_data.ysize
672
+ next if @flash_data[i, j] == 0
673
+ x = i * 32
674
+ y = j * 32
675
+ r = ((@flash_data[i, j] / 256) % 16) * 255 / 15
676
+ g = ((@flash_data[i, j] / 16) % 16) * 255 / 15
677
+ b = (@flash_data[i, j] % 16) * 255 / 15
678
+ c = Color.new(r, g, b)
679
+ c2 = Color.new(r - 32, g - 32, b - 32)
680
+ bmp.fill_rect(x,y,32,32,c)
681
+
682
+ end
683
+ end
684
+ end
685
+
686
+ end