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
|
module RPG
module Cache
AUTOTILES = [26, 27, 32, 33, 4, 27, 32, 33, # 1
5, 27, 32, 33, 4, 5, 32, 33, # 3
26, 27, 32, 11, 4, 27, 32, 11, # 5
26, 5, 32, 11, 4, 5, 32, 11, # 7
26, 27, 10, 33, 4, 27, 10, 33, # 9
26, 5, 10, 33, 4, 5, 10, 33, # 11
26, 27, 10, 11, 4, 27, 10, 11, # 13
26, 5, 10, 11, 4, 5, 10, 11, # 15
24, 25, 30, 31, 24, 5, 30, 31, # 17
24, 25, 30, 11, 24, 5, 30, 11, # 19
14, 15, 20, 21, 14, 15, 20, 11, # 21
14, 15, 10, 21, 14, 15, 10, 11, # 23
28, 29, 34, 35, 28, 29, 10, 35, # 25
4, 29, 34, 35, 4, 29, 10, 35, # 27
38, 39, 44, 45, 4, 39, 44, 45, # 29
38, 5, 44, 45, 4, 5, 44, 45, # 31
24, 29, 30, 35, 14, 15, 44, 45, # 33
12, 13, 18, 19, 12, 13, 18, 11, # 35
16, 17, 22, 23, 16, 17, 10, 23, # 37
40, 41, 46, 47, 4, 41, 46, 47, # 39
36, 37, 42, 43, 36, 5, 42, 43, # 41
12, 17, 18, 23, 12, 13, 42, 43, # 43
36, 41, 42, 47, 16, 17, 46, 47, # 45
0, 1, 6, 7, 0, 1, 6, 7] # 47
module_function
def atile(file, id)
autotile_bitmap = Bitmap.new(32, 32)
autotiles_bitmap = autotile(file)
real_id = id * 4
rect = Array.new(4) {|i| Rect.new(AUTOTILES[real_id + i] % 6 * 16, AUTOTILES[real_id + i] / 6 * 16, 16, 16)}
autotile_bitmap.blt(0, 0, autotiles_bitmap, rect[0])
autotile_bitmap.blt(16, 0, autotiles_bitmap, rect[1])
autotile_bitmap.blt(0, 16, autotiles_bitmap, rect[2])
autotile_bitmap.blt(16, 16, autotiles_bitmap, rect[3])
return autotile_bitmap
end
end
end |