Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Squall's MiniMap

Teepo

Member

I remember squall posted a mini-map script in the .net forums. And if it was reposted here, its definatly not around anymore thanks to the hacker. so if anyone has this, it would be great if you could post it.. i accidently deleted the script in my game >,<
 
All credits to Squall of course

This is my little christmas present for you all!

NOTE1 : Great thanks to Fanha Giang (aka Fanha99) for the autotile drawing method!
NOTE2 : you can easily modifiy the dots, the border and the autotile to make it look radically different!


Quote

FIXES :
- use of standard autotiles
- no passability display
- allows to switch between normal mode and object mode (draw passability of objects such as trees...)
- on/off toggling added
- enhanced the code and supports of large maps (it's not working up to 500*500 maps still. But I'm working on fixing this...)
- removed lag with big maps


IMPORTANT : YOU NEED TO SET WHAT SWITCH YOU'RE USING FOR THE OBJECT DRAWING. IT'S SWITCH 1 BY DEFAULT. TO CHANGE IT GO IN MAP_BASE AND CHANGE THE NUMBER OF OBJECT_ID (search for OBJECT_ID =).
SAME GOES FOR WHETHER YOU WANT TO DISPLAY THE MINIMAP OR NOT. IT'S SWITCH 2 BY DEFAULT. TO CHANGE IT GO IN MAP_BASE AND CHANGE THE NUMBER OF ACTIVATED_ID (search for ACTIVATED_ID =)

What does this do?
this draws a mini map in a corner of the screen showing the player where he can walk and where he can't.
(look at the screenie you'll understand)

On the mini-map you can display some event's position. by putting a comment inside an event, if the comment is either one of the following : "event" ; "enemy" ; "teleport" ; "chest" ; "npc" ; "savepoint"

the files you need :

the dots and the mini-map border (download them in the picture folder)

http://img131.imageshack.us/img131/9743/mapback0ro.png[/IMG]


on requested by bluescope : (remember the border you use must be named 'mapback')

http://img157.imageshack.us/img157/3148/mapbackfade5zh.png[/IMG]

http://img131.imageshack.us/img131/1593/chest7ym.png[/IMG]

http://img157.imageshack.us/img157/2173/enemy4lt.png[/IMG]

http://img131.imageshack.us/img131/1831/event9tp.png[/IMG]

http://img131.imageshack.us/img131/7301/hero6nf.png[/IMG]

http://img157.imageshack.us/img157/8496/npc7bw.png[/IMG]

http://img131.imageshack.us/img131/8243/savepoint9rm.png[/IMG]

http://img157.imageshack.us/img157/1994/teleport3kd.png[/IMG]

the autotile (download it in the autotile folder)

http://img157.imageshack.us/img157/5672/minimap4gp.png[/IMG]

and another autotile (remember that the autotile you use must be named 'minimap')

http://img131.imageshack.us/img131/5504/minimap23bn.png[/IMG]

the script : (to be pasted in a new section above main)

#==============================================================================
# â–  Passability Mini Map
#------------------------------------------------------------------------------
# made by squall // squall@loeher.zzn.com
# released on 20 December 2005
#==============================================================================

#==============================================================================
# â–  Scene_Map
#------------------------------------------------------------------------------
#  draw the mini map
# @corner is the corner you want the mini map to be displayed in.
# 1 is upper left, 2 is upper right, 3 is bottom left and 4 is bottom right
#==============================================================================

class Scene_Map
alias main_passminimap main
alias update_passminimap update
alias transfer_passminimap transfer_player
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize
@corner = 4 # 1 or 2 or 3 or 4
end
#--------------------------------------------------------------------------
# ● main
#--------------------------------------------------------------------------
def main
@mini_map = Map_Event.new(@corner)
main_passminimap
@mini_map.dispose
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def update
@mini_map.update
if $game_system.map_interpreter.running?
@mini_map.visible = false
elsif not $game_system.map_interpreter.running? and @mini_map.on?
@mini_map.visible = true
end
update_passminimap
end
#--------------------------------------------------------------------------
# ● transfer_player
#--------------------------------------------------------------------------
def transfer_player
transfer_passminimap
@mini_map.dispose
@mini_map = Map_Event.new(@corner)
end
end

#==============================================================================
# â–  Map_Base
#------------------------------------------------------------------------------
#  Base class for mini maps
#==============================================================================

class Map_Base < Sprite
#--------------------------------------------------------------------------
# ● constants and instances
#--------------------------------------------------------------------------
PMP_VERSION = 5
OBJECT_ID = 1 # set the switch id for the object drawing autorisation
ACTIVATED_ID = 2 # set the switch id for the minimap display (on/off)
attr_reader :event
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize(corner)
super(nil)
self.z = 8000
case corner
when 1
self.x = 16
self.y = 16
when 2
self.x = 640 - width - 16
self.y = 16
when 3
self.x = 16
self.y = 480 - height - 16
when 4
self.x = 640 - width - 16
self.y = 480 - height - 16
else
self.x = 16
self.y = 16
end
@draw_object = draw_object?
@event = Sprite.new
@event.x, @event.y, @event.z = self.x, self.y, self.z
@event.bitmap = Bitmap.new(160, 120)
@border = Sprite.new
@border.x, @border.y, @border.z = self.x - 8, self.y - 8, self.z
@border.bitmap = RPG::Cache.picture("mapback")
@temp_x = $game_player.real_x
@temp_y = $game_player.real_y
self.visible = on?
end
#--------------------------------------------------------------------------
# ● draw_object?
#--------------------------------------------------------------------------
def draw_object?
return $game_switches[OBJECT_ID]
end
#--------------------------------------------------------------------------
# ● minimap_on?
#--------------------------------------------------------------------------
def on?
return $game_switches[ACTIVATED_ID]
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def update
super
self.visible = on?
if self.src_rect.x < display_x
self.src_rect.x += 1
elsif self.src_rect.x > display_x
self.src_rect.x -= 1
end
if self.src_rect.y < display_y
self.src_rect.y += 1
elsif self.src_rect.y > display_y
self.src_rect.y -= 1
end
if @temp_x != $game_player.real_x or @temp_y != $game_player.real_y
@temp_x = $game_player.real_x
@temp_y = $game_player.real_y
refresh_event_map
end
if @draw_object != draw_object?
@draw_object = draw_object?
setup($game_map.map_id)
end
end
#--------------------------------------------------------------------------
# ● dispose
#--------------------------------------------------------------------------
def dispose
super
@event.dispose
@border.dispose
end
#--------------------------------------------------------------------------
# ● visible=
#--------------------------------------------------------------------------
def visible=(bool)
super
@event.visible = bool
@border.visible = bool
end
#--------------------------------------------------------------------------
# ● width
#--------------------------------------------------------------------------
def width
return 160
end
#--------------------------------------------------------------------------
# ● height
#--------------------------------------------------------------------------
def height
return 120
end
#--------------------------------------------------------------------------
# ● display_x
#--------------------------------------------------------------------------
def display_x
return $game_map.display_x / 16
end
#--------------------------------------------------------------------------
# ● display_y
#--------------------------------------------------------------------------
def display_y
return $game_map.display_y / 16
end
end

#==============================================================================
# â–  Map_Passability
#------------------------------------------------------------------------------
# draws the mini map
#
#  thanks to Fanha Giang (aka fanha99) for the autotile drawing method
#==============================================================================

class Map_Passability < Map_Base
#--------------------------------------------------------------------------
# ● instances
#--------------------------------------------------------------------------
INDEX =
[
26, 27, 32, 33, 4, 27, 32, 33, 26, 5, 32, 33, 4, 5, 32, 33,
26, 27, 32, 11, 4, 27, 32, 11, 26, 5, 32, 11, 4, 5, 32, 11,
26, 27, 10, 33, 4, 27, 10, 33, 26, 5, 10, 33, 4, 5, 10, 33,
26, 27, 10, 11, 4, 27, 10, 11, 26, 5, 10, 11, 4, 5, 10, 11,
24, 25, 30, 31, 24, 5, 30, 31, 24, 25, 30, 11, 24, 5, 30, 11,
14, 15, 20, 21, 14, 15, 20, 11, 14, 15, 10, 21, 14, 15, 10, 11,
28, 29, 34, 35, 28, 29, 10, 35, 4, 29, 34, 35, 4, 29, 10, 35,
38, 39, 44, 45, 4, 39, 44, 45, 38, 5, 44, 45, 4, 5, 44, 45,
24, 29, 30, 35, 14, 15, 44, 45, 12, 13, 18, 19, 12, 13, 18, 11,
16, 17, 22, 23, 16, 17, 10, 23, 40, 41, 46, 47, 4, 41, 46, 47,
36, 37, 42, 43, 36, 5, 42, 43, 12, 17, 18, 23, 12, 13, 42, 43,
36, 41, 42, 47, 16, 17, 46, 47, 12, 17, 42, 47, 0, 1, 6, 7
]
X = [0, 1, 0, 1]
Y = [0, 0, 1, 1]
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize(corner = 4)
super(corner)
temp = RPG::Cache.autotile("minimap")
@autotile = Bitmap.new(24, 32)
@autotile.stretch_blt(Rect.new(0, 0, 24, 32), temp, Rect.new(0, 0, 96, 128))
setup($game_map.map_id)
end
#--------------------------------------------------------------------------
# ● setup
#--------------------------------------------------------------------------
def setup(map_id)
@map_id = map_id
@map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
tileset = $data_tilesets[@map.tileset_id]
@passages = tileset.passages
@priorities = tileset.priorities
redefine_tiles
refresh
end
#--------------------------------------------------------------------------
# ● pass
#--------------------------------------------------------------------------
def pass(tile_id)
return 15 if tile_id == nil
return @passages[tile_id] != nil ? @passages[tile_id] : 15
end
#--------------------------------------------------------------------------
# ● redefine_tile
#--------------------------------------------------------------------------
def redefine_tiles
width = @map.width
height = @map.height
map = RPG::Map.new(width, height)
map.data = @map.data.dup
RPG::Cache.clear
for y in 0...height
for x in 0...width
for level in [0, 1, 2]
id = @map.data[x, y, level]
@passages[id] = 15 if pass(id) == 31
next if level == 0
if pass(id) != 15 and @priorities[id] == 0
@map.data[x, y, 0] = 384
elsif pass(id) == 15 and id.between?(48, 383)
@map.data[x, y, 0] = id
@passages[@map.data[x, y, 0]] = pass(id)
elsif pass(id) == 15 and @priorities[id] == 0 and draw_object?
@map.data[x, y, 0] = 48
end
end
end
end
for y in 0...height
for x in 0...width
tile = @map.data[x, y, 0]
u = @map.data[x, y - 1, 0]
d = @map.data[x, y + 1, 0]
r = @map.data[x + 1, y, 0]
l = @map.data[x - 1, y, 0]
ul = @map.data[x - 1, y - 1, 0]
ur = @map.data[x + 1, y - 1, 0]
dl = @map.data[x - 1, y + 1, 0]
dr = @map.data[x + 1, y + 1, 0]
map.data[x, y, 0] = 94
if pass(tile) == 15
if pass(u) != 15 and pass(r) != 15 and pass(l) != 15 and pass(d) != 15
map.data[x, y, 0] = 94
end
if pass(u) != 15 and pass(r) != 15 and pass(l) != 15 and pass(d) == 15
map.data[x, y, 0] = 90
end
if pass(u) != 15 and pass(r) != 15 and pass(d) != 15 and pass(l) == 15
map.data[x, y, 0] = 93
end
if pass(u) != 15 and pass(r) != 15 and pass(l) == 15 and pass(d) == 15
map.data[x, y, 0] = 84
end
if pass(u) != 15 and pass(l) != 15 and pass(d) != 15 and pass(r) == 15
map.data[x, y, 0] = 91
end
if pass(u) != 15 and pass(l) != 15 and pass(r) == 15 and pass(d) == 15
map.data[x, y, 0] = 82
end
if pass(u) != 15 and pass(d) != 15 and pass(r) == 15 and pass(l) == 15
map.data[x, y, 0] = 81
end
if pass(u) != 15 and pass(r) == 15 and pass(l) == 15 and pass(d) == 15
map.data[x, y, 0] = 68
end
if pass(r) != 15 and pass(l) != 15 and pass(d) != 15 and pass(u) == 15
map.data[x, y, 0] = 92
end
if pass(r) != 15 and pass(l) != 15 and pass(u) == 15 and pass(d) == 15
map.data[x, y, 0] = 80
end
if pass(r) != 15 and pass(d) != 15 and pass(u) == 15 and pass(l) == 15
map.data[x, y, 0] = 86
end
if pass(r) != 15 and pass(u) == 15 and pass(l) == 15 and pass(d) == 15
map.data[x, y, 0] = 72
end
if pass(l) != 15 and pass(d) != 15 and pass(u) == 15 and pass(r) == 15
map.data[x, y, 0] = 88
end
if pass(l) != 15 and pass(u) == 15 and pass(r) == 15 and pass(d) == 15
map.data[x, y, 0] = 64
end
if pass(d) != 15 and pass(u) == 15 and pass(r) == 15 and pass(l) == 15
map.data[x, y, 0] = 76
end
if pass(u) == 15 and pass(r) == 15 and pass(l) == 15 and pass(d) == 15
map.data[x, y, 0] = 48
end
else
map.data[x, y, 0] = 384
end
end
end
@map = map.dup
map = nil
end
#--------------------------------------------------------------------------
# ● refresh
#--------------------------------------------------------------------------
def refresh
self.visible = false
self.bitmap = Bitmap.new(@map.width * 8, @map.height * 8)
bitmap = Bitmap.new(@map.width * 8, @map.height * 8)
rect1 = Rect.new(8, 0, 8, 8)
for y in 0...@map.height
for x in 0...@map.width
tile_id = @map.data[x, y, 0]
if tile_id >= 384
bitmap.blt(x * 8, y * 8, @autotile, rect1)
end
if tile_id >= 48 and tile_id < 384
id = tile_id / 48 - 1
tile_id %= 48
for g in 0..3
h = 4 * tile_id + g
y1 = INDEX[h] / 6
x1 = INDEX[h] % 6
rect2 = Rect.new(x1 * 4, y1 * 4, 4, 4)
bitmap.blt(x * 8 + X[g] * 4, y * 8 + Y[g] * 4, @autotile, rect2)
end
end
end
end
d_rect = Rect.new(0, 0, @map.width * 8, @map.height * 8)
s_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.bitmap.stretch_blt(d_rect, bitmap, s_rect)
self.src_rect.set(display_x, display_y, width, height)
bitmap.clear
bitmap.dispose
end
end

#==============================================================================
# â–  Map_Event
#------------------------------------------------------------------------------
#  draw the events and hero position
#==============================================================================

class Map_Event < Map_Passability
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize(corner = 4)
super(corner)
@dots = []
refresh_event_map
end
#--------------------------------------------------------------------------
# ● refresh_dots
#--------------------------------------------------------------------------
def refresh_events
for event in $game_map.events.values
bitmap = nil
x = event.x * 8 - display_x
y = event.y * 8 - display_y
next if event.list == nil
for i in 0...event.list.size
if event.list.parameters[0].is_a?(String)
if event.list.parameters[0] == "event"
bitmap = RPG::Cache.picture(event.list.parameters[0])
break
elsif event.list.parameters[0] == "enemy"
bitmap = RPG::Cache.picture(event.list.parameters[0])
break
elsif event.list.parameters[0].include?("teleport")
bitmap = RPG::Cache.picture("teleport")
break
elsif event.list.parameters[0] == "chest"
bitmap = RPG::Cache.picture(event.list.parameters[0])
break
elsif event.list.parameters[0] == "npc"
bitmap = RPG::Cache.picture(event.list.parameters[0])
break
elsif event.list.parameters[0] == "savepoint"
bitmap = RPG::Cache.picture(event.list.parameters[0])
break
else
bitmap = nil
end
end
end
@dots.push([x, y, bitmap])
end
end
#--------------------------------------------------------------------------
# ● refresh_dots
#--------------------------------------------------------------------------
def refresh_player
x = $game_player.real_x / 16 - display_x
y = $game_player.real_y / 16 - display_y
bitmap = RPG::Cache.picture("hero")
@dots.push([x, y, bitmap])
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def refresh_event_map
@dots.clear
self.event.bitmap.clear
refresh_events
refresh_player
for dot in @dots
unless dot[2] == nil
self.event.bitmap.blt(dot[0], dot[1], dot[2], Rect.new(0, 0, 8, 8))
end
end
end
end


screenie :

http://img157.imageshack.us/img157/959/mapmap1rs6jn.png[/IMG]

Give credit, Enjoy!

Tis that OK?
 

jas0n

Member

I dont get it~
After i name the first picture mapback
what the 2nd picture name? mapback again?
Same as minimap

Helper needed~~
 
That's an alternate mapback if you don't want to use the original, Name it mapback2 if you don't want to use it or just delete it same with the autotiles if you feel you like one more than the other then use it otherwise name it minimap2 or delete it.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top