###############################################
# Autor: Resque
# Mail: rogessonb@gmail.com
# Date: 14/04/2017
#
# Name Resque Minimap Script - Version 1.0
#
# Engine: RPG Maker VX Ace
#
# Description:
#
# An automap generator, you don't need to create images or
# get data from the map, this script finds the map structure and
# create a minimap automatically.
###############################################
module ResqueMiniMapConfig
# The colors is based on RGB grade
HERO_COLOR = [255, 0, 0] # RED
MAP_COLOR = [255, 255, 255] # White
MAP_BACK_COLOR = [0, 0, 0] # Black
# Hero pixel size
HERO_SIZE = 5
# MiniMap Size
WIDTH = 100
HEIGHT = 100
# Hero initial Position
HERO_POSITION = 48
end
class Scene_Map < Scene_Base
alias resque_start start
def start
resque_start
@resque_mini_map = Resque_MiniMap.new
end
alias resque_update update
def update
resque_update
@resque_mini_map.update
end
alias resque_terminate terminate
def terminate
resque_terminate
@resque_mini_map.dispose
end
end
class Resque_MiniMap
include ResqueMiniMapConfig
def initialize
create_background
create_hero
fill_map
update
end
def update
x = (($game_player.x * 6) * -1) + HERO_POSITION
y = (($game_player.y * 8) * -1) + HERO_POSITION
@back_sprite.x = x if @back_sprite.x != x
@back_sprite.y = y if @back_sprite.y != y
@back_sprite.src_rect.set(0, 0, ($game_player.x * 6) + HERO_POSITION, ($game_player.y * 8) + HERO_POSITION )
end
def dispose
@back_sprite.dispose
@hero_bitmap.dispose
end
private
def create_background
@back_bitmap = Bitmap.new($game_map.width * WIDTH, $game_map.height * HEIGHT)
@back_sprite = Sprite.new
@back_sprite.bitmap = @back_bitmap
@back_sprite.z = 300
end
def create_hero
@hero_bitmap = Bitmap.new(HERO_SIZE, HERO_SIZE)
rect_hero = Rect.new(0, 0, HERO_SIZE, HERO_SIZE)
hero_color = Color.new(HERO_COLOR[0], HERO_COLOR[1], HERO_COLOR[2], 255)
@hero_bitmap.fill_rect(rect_hero, hero_color)
@sprite_hero = Sprite.new
@sprite_hero.bitmap = @hero_bitmap
set_hero_position
end
def set_hero_position
@sprite_hero.x = HERO_POSITION
@sprite_hero.y = HERO_POSITION
@sprite_hero.z = 301
end
def fill_map
@viewport = Viewport.new
@tilemap = Tilemap.new(@viewport)
@tilemap.map_data = $game_map.data
back_color = Color.new(MAP_BACK_COLOR[0], MAP_BACK_COLOR[1], MAP_BACK_COLOR[2], 160)
@back_bitmap.fill_rect(@back_bitmap.rect, back_color)
load_tileset
end
def load_tileset
x = 0
y = 0
width = $game_map.width
height = $game_map.height
height.times do
width.times do
create_tile(x, y)
x += 1
end
x = 0
y += 1
end
end
def create_tile(x, y)
if $game_map.passable?(x, y, 6)
bitmap = Bitmap.new(HERO_SIZE, HERO_SIZE)
rect = Rect.new(0, 0, HERO_SIZE, HERO_SIZE)
color = Color.new(MAP_COLOR[0], MAP_COLOR[1], MAP_COLOR[2], 255)
bitmap.fill_rect(rect, color)
@back_sprite.bitmap.blt(x * 6, y * 8, bitmap, rect)
end
end
end