Templo RPG Maker
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Você não está conectado. Conecte-se ou registre-se

Ver o tópico anterior Ver o tópico seguinte Ir para baixo  Mensagem [Página 1 de 1]

The Lucas Wugades

The Lucas Wugades
Membro Honorário III
Membro Honorário III
Introdução



Faz um mine-mapa sem prescisar de imagens

Código:
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================

class Spriteset_Map
#--------------------------------------------------------------------------
# * Create Tilemap
#--------------------------------------------------------------------------
def create_tilemap
@tilemap = Tilemap.new(@viewport1)
@tilemap.bitmaps[0] = Cache.system("TileA1")
@tilemap.bitmaps[1] = Cache.system("TileA2")
@tilemap.bitmaps[2] = Cache.system("TileA3")
@tilemap.bitmaps[3] = Cache.system("TileA4")
@tilemap.bitmaps[4] = Cache.system("TileA5")
@tilemap.bitmaps[5] = Cache.system("TileB")
@tilemap.bitmaps[6] = Cache.system("TileC")
@tilemap.bitmaps[7] = Cache.system("TileD")
@tilemap.bitmaps[8] = Cache.system("TileE")
@tilemap.map_data = $game_map.data
@tilemap.passages = $game_map.passages
# ▼ CREATE THE MINIMAP
create_minimap
end


#--------------------------------------------------------------------------
# ● Kalkazad's Create Minimap yey ^_^
#--------------------------------------------------------------------------
def create_minimap
# ● mapsize
w = $game_map.width
h = $game_map.height

# ● minimapsize
zoom = 2.0
minimap_width = (zoom*56).to_i
minimap_height = (zoom*56).to_i

expand = (16/zoom).to_i
minimap_w = minimap_width * expand
minimap_h = minimap_height * expand

# ● tilesize
dim_w = minimap_w / w
dim_h = minimap_h / h
if dim_w <= dim_h
dim = dim_w
else
dim = dim_h
end

start_x = 0
start_y = 0
occu = 200

# ● create the minimap
@minimap = Bitmap.new(w*dim, h*dim)

if ((w+h) > 110)
rgss_error = true
else
rgss_error = false
end
if rgss_error
id_file = File.new("tile_index.tix", "w")
end


for z in 0..2
for y in 0..$game_map.height-1
for x in 0..$game_map.width-1
tile_id = @tilemap.map_data[x,y,z]
pos_x = start_x + x*dim
pos_y = start_y + y*dim
if rgss_error
s = "x:" + x.to_s + " y:" + y.to_s + " z:" + z.to_s
id_file << s
end
tile = get_tile(tile_id)
rect_dim = Rect.new(pos_x, pos_y, dim, dim)
rect_tile = tile.rect
@minimap.stretch_blt(rect_dim, tile, rect_tile, occu)
end
end
end

if rgss_error
id_file.close
File.delete("tile_index.tix")
end


# ● show the minimap (just for testing)
view_TEST = Viewport.new(416,0,minimap_width,minimap_height)
@plane_TEST = Sprite.new(view_TEST)
@plane_TEST.bitmap = @minimap
@plane_TEST.zoom_x = (1.0 / expand)
@plane_TEST.zoom_y = (1.0 / expand)
end #def create_tilemap

#--------------------------------------------------------------------------
# ● get_tile
#--------------------------------------------------------------------------
def get_tile(tile_id)
tile = Bitmap.new(32,32)
# ---------- A1 ----------------
@a1 = [16]
@a1[0] = 2048
for i in 1..15
@a1[i] = @a1[i-1]+48
end
# ---------- A2 ----------------
@a2 = [32]
@a2[0] = 2816
for i in 1..31
@a2[i] = @a2[i-1]+48
end
# ---------- A3 ----------------
@a3 = [32]
@a3[0] = 4352
for i in 1..31
@a3[i] = @a3[i-1]+48
end
# ---------- A4 ----------------
@a4 = [48]
@a4[0] = 5888
for i in 1..47
@a4[i] = @a4[i-1]+48
end

if tile_id > 5886 #A4
for i in 0..47
if ((tile_id >= @a4[i]) && (tile_id <= (@a4[i]+46)))
auto_tile = get_auto_tile(tile_id,@a4[i]-1,3)
break
end
end
tile_rect = Rect.new(0,0,32,32)
tile.blt(0,0,auto_tile,tile_rect,255)
elsif tile_id > 4350 #A3
for i in 0..31
if ((tile_id >= @a3[i]) && (tile_id <= (@a3[i]+46)))
auto_tile = get_auto_tile(tile_id,@a3[i]-1,2)
break
end
end
tile_rect = Rect.new(0,0,32,32)
tile.blt(0,0,auto_tile,tile_rect,255)
elsif tile_id > 2800 #A2
for i in 0..31
if ((tile_id >= @a2[i]) && (tile_id <= (@a2[i]+46)))
auto_tile = get_auto_tile(tile_id,@a2[i]-1,1)
break
end
end
tile_rect = Rect.new(0,0,32,32)
tile.blt(0,0,auto_tile,tile_rect,255)
elsif tile_id > 2000 #A1
for i in 0..15
if ((tile_id >= @a1[i]) && (tile_id <= (@a1[i]+46)))
auto_tile = get_auto_tile(tile_id,@a1[i]-1,0)
break
end
end
tile_rect = Rect.new(0,0,32,32)
tile.blt(0,0,auto_tile,tile_rect,255)
elsif tile_id > 1500 #A5
start_x = 0
start_y = 0
tile_pos = tile_id - 1536
pos_y = (tile_pos*1.00) / (8.00)
pos_x = (tile_pos*1.00) % (8.00)
pos_x = pos_x.to_i
pos_y = pos_y.to_i
x = start_x + 32*pos_x
y = start_y + 32*pos_y
tile_rect = Rect.new(x,y,32,32)
tilemap = @tilemap.bitmaps[4]
tile.blt(0,0,tilemap,tile_rect,255)
elsif ((tile_id > 0) && (tile_id < 1024)) #B-E
if tile_id >= 768
tilemap = @tilemap.bitmaps[8] #E
tile_pos = tile_id - 3*256
elsif tile_id >= 512
tilemap = @tilemap.bitmaps[7] #D
tile_pos = tile_id - 2*256
elsif tile_id >= 256
tilemap = @tilemap.bitmaps[6] #C
tile_pos = tile_id - 1*256
elsif tile_id >= 0
tilemap = @tilemap.bitmaps[5] #B
tile_pos = tile_id
end #if
if tile_pos < 128
start_x = 0
pos_y = (tile_pos / 8).to_i
else
start_x = 8*32
pos_y = ((tile_pos-128) / 8).to_i
end #if
pos_x = tile_pos % 8
x = start_x + 32*pos_x
y = 32*pos_y
tile_rect = Rect.new(x,y,32,32)
tile.blt(0,0,tilemap,tile_rect,255)
end #if
return tile
end #def get_tile(tile_id)

#--------------------------------------------------------------------------
# ● get_auto_tile
#--------------------------------------------------------------------------
def get_auto_tile(tile_id, tile_correcture, tilemap_index)
automap = @tilemap.bitmaps[tilemap_index]
auto = Bitmap.new(32,32)
auto_id = tile_id - tile_correcture
field = tile_correcture + 1
case tilemap_index
when 0 #A1
autotyp = 32
case field
when @a1[0]
start_x = 0
start_y = 0
when @a1[1]
start_x = 0
start_y = 3
when @a1[2]
start_x = 6
start_y = 0
when @a1[3]
start_x = 6
start_y = 3
when @a1[4]
start_x = 8
start_y = 0
when @a1[5]
start_x = 14
start_y = 0
when @a1[6]
start_x = 8
start_y = 3
when @a1[7]
start_x = 14
start_y = 3
when @a1[8]
start_x = 0
start_y = 6
when @a1[9]
start_x = 6
start_y = 6
when @a1[10]
start_x = 0
start_y = 9
when @a1[11]
start_x = 6
start_y = 9
when @a1[12]
start_x = 8
start_y = 6
when @a1[13]
start_x = 14
start_y = 6
when @a1[14]
start_x = 8
start_y = 9
when @a1[15]
start_x = 14
start_y = 9
end #case field
when 1 #A2
autotyp = 32
n = 0;
for i in 0..31
if ((field - i*48) == @a2[0])
n = i
break
end
end
start_x = 2*(n%8)
start_y = 3*(n/8).to_i
when 2 #A3
autotyp = 22
n = 0;
for i in 0..31
if ((field - i*48) == @a3[0])
n = i
break
end
end
start_x = 2*(n%8)
start_y = 2*(n/8).to_i
when 3 #A4
autotyp = 32
n = 0;
for i in 0..47
if ((field - i*48) == @a4[0])
n = i
break
end
end
start_x = 2*(n%8)
start_y = (n/8).to_i
case start_y
when 1
start_y = 3
autotyp = 22
when 2
start_y = 5
when 3
start_y = 8
autotyp = 22
when 4
start_y = 10
when 5
start_y = 13
autotyp = 22
end
end #case tilemap_index

case autotyp
when 22
upper = Array.new(4, 0)
lower = Array.new(4, 0)
case auto_id
when 1
upper = [1, 1, 2, 1]
lower = [1, 2, 2, 2]
when 2
upper = [0, 1, 1, 1]
lower = [0, 2, 1, 2]
when 3
upper = [1, 0, 2, 0]
lower = [1, 1, 2, 1]
when 4
upper = [0, 0, 1, 0]
lower = [0, 1, 1, 1]
when 5
upper = [2, 1, 3, 1]
lower = [2, 2, 3, 2]
when 6
upper = [0, 1, 3, 1]
lower = [0, 2, 3, 2]
when 7
upper = [2, 0, 3, 0]
lower = [2, 1, 3, 1]
when 8
upper = [0, 0, 3, 0]
lower = [0, 1, 3, 1]
when 9
upper = [1, 2, 2, 2]
lower = [1, 3, 2, 3]
when 10
upper = [0, 2, 1, 2]
lower = [0, 3, 1, 3]
when 11
upper = [1, 0, 2, 0]
lower = [1, 3, 2, 3]
when 12
upper = [0, 0, 1, 0]
lower = [0, 3, 1, 3]
when 13
upper = [2, 2, 3, 2]
lower = [2, 3, 3, 3]
when 14
upper = [0, 2, 3, 2]
lower = [0, 3, 3, 3]
when 15
upper = [2, 0, 3, 0]
lower = [2, 3, 3, 3]
when 16
upper = [0, 0, 3, 0]
lower = [0, 3, 3, 3]
end #case
when 32
upper = Array.new(4, 0)
lower = Array.new(4, 0)
case auto_id
when 1
upper = [1, 3, 2, 3]
lower = [1, 4, 2, 4]
when 2
upper = [2, 0, 2, 3]
lower = [1, 4, 2, 4]
when 3
upper = [1, 3, 3, 0]
lower = [1, 4, 2, 4]
when 4
upper = [2, 0, 3, 0]
lower = [1, 3, 2, 3]
when 5
upper = [1, 3, 2, 3]
lower = [1, 4, 3, 1]
when 6
upper = [2, 0, 2, 3]
lower = [1, 4, 3, 1]
when 7
upper = [2, 3, 3, 0]
lower = [2, 4, 3, 1]
when 8
upper = [2, 0, 3, 0]
lower = [1, 4, 3, 1]
when 9
upper = [1, 3, 2, 3]
lower = [2, 1, 2, 4]
when 10
upper = [2, 0, 1, 3]
lower = [2, 1, 1, 4]
when 11
upper = [1, 3, 3, 0]
lower = [2, 1, 2, 4]
when 12
upper = [2, 0, 3, 0]
lower = [2, 1, 2, 4]
when 13
upper = [1, 4, 2, 4]
lower = [2, 1, 3, 1]
when 14
upper = [2, 0, 2, 3]
lower = [2, 1, 3, 1]
when 15
upper = [1, 3, 3, 0]
lower = [2, 1, 3, 1]
when 16
upper = [2, 0, 3, 0]
lower = [2, 1, 3, 1]
when 17
upper = [0, 3, 1, 3]
lower = [0, 4, 1, 4]
when 18
upper = [0, 3, 3, 0]
lower = [0, 4, 1, 4]
when 19
upper = [0, 3 ,1 ,3]
lower = [0, 4 ,3 ,1]
when 20
upper = [0, 3, 3, 0]
lower = [0, 4, 3, 1]
when 21
upper = [1, 2, 2, 2]
lower = [1, 3, 2, 3]
when 22
upper = [1, 2, 2, 2]
lower = [1, 3, 3, 1]
when 23
upper = [1, 2, 2, 2]
lower = [2, 1, 2, 3]
when 24
upper = [1, 2, 2, 2]
lower = [2, 1, 3, 1]
when 25
upper = [2, 3, 3, 3]
lower = [2, 4, 3, 4]
when 26
upper = [2, 3, 3, 3]
lower = [2, 1, 3, 4]
when 27
upper = [2, 0, 3, 3]
lower = [2, 4, 3, 4]
when 28
upper = [2, 0, 3, 3]
lower = [2, 1, 3, 4]
when 29
upper = [1, 4, 2, 4]
lower = [1, 5, 2, 5]
when 30
upper = [2, 0, 2, 4]
lower = [1, 5, 2, 5]
when 31
upper = [1, 4, 3, 0]
lower = [1, 5, 2, 5]
when 32
upper = [2, 0, 3, 0]
lower = [1, 5, 2, 5]
when 33
upper = [0, 3, 3, 3]
lower = [0, 4, 3, 4]
when 34
upper = [1, 2, 2, 2]
lower = [1, 5, 2, 5]
when 35
upper = [0, 2, 1, 2]
lower = [0, 3, 1, 3]
when 36
upper = [0, 2, 1, 2]
lower = [0, 3, 3, 1]
when 37
upper = [2, 2, 3, 2]
lower = [2, 3, 3, 3]
when 38
upper = [2, 2, 3, 2]
lower = [2, 1, 3, 3]
when 39
upper = [2, 4, 3, 4]
lower = [2, 5, 3, 5]
when 40
upper = [2, 0, 3, 4]
lower = [2, 5, 3, 5]
when 41
upper = [0, 4, 1, 4]
lower = [0, 5, 1, 5]
when 42
upper = [0, 4, 3, 0]
lower = [0, 5, 1, 5]
when 43
upper = [0, 0, 1, 0]
lower = [0, 3, 3, 3]
when 44
upper = [0, 0, 1, 2]
lower = [0, 1, 1, 5]
when 45
upper = [0, 4, 3, 4]
lower = [0, 1, 1, 1]
when 46
upper = [2, 2, 1, 0]
lower = [2, 5, 1, 1]
when 47
upper = [2, 2, 0, 1]
lower = [2, 5, 1, 1]
end #case
end #case autotyp
for f in 0..3
upper[f] *= 16
lower[f] *= 16
if ((f % 2) == 0)
upper[f] += start_x*32
lower[f] += start_x*32
else
upper[f] += start_y*32
lower[f] += start_y*32
end
end
auto_rect_ol = Rect.new(upper[0],upper[1],16,16)
auto_rect_or = Rect.new(upper[2],upper[3],16,16)
auto_rect_ul = Rect.new(lower[0],lower[1],16,16)
auto_rect_ur = Rect.new(lower[2],lower[3],16,16)
auto.blt(0,0,automap,auto_rect_ol,255)
auto.blt(16,0,automap,auto_rect_or,255)
auto.blt(0,16,automap,auto_rect_ul,255)
auto.blt(16,16,automap,auto_rect_ur,255)
return auto
end #def get_auto_tile(tile_id, tile_correcture, tilemap_index)

end #class

Creditos:

Desconhecido

https://templorpgmakerbr.forumeiros.com/forum

BrunoFox

BrunoFox
Administrador
Administrador
Tem screen?

https://templorpgmakerbr.forumeiros.com

The Lucas Wugades

The Lucas Wugades
Membro Honorário III
Membro Honorário III
Tou fazendo um mapa bonito pra colocar a screen pra atrair mais

https://templorpgmakerbr.forumeiros.com/forum

BrunoFox

BrunoFox
Administrador
Administrador
Ok, no aguardo.

https://templorpgmakerbr.forumeiros.com

Conteúdo patrocinado


Ver o tópico anterior Ver o tópico seguinte Ir para o topo  Mensagem [Página 1 de 1]

Permissões neste sub-fórum
Não podes responder a tópicos