RPGXP/VX 미니맵을 만들어 보자 - 스크립트 -
2006.09.06 03:01
미니맵 스크립트 입니다
위치는 왼쪽 위가 아니고
왼쪽 아래입니다~ 그리고 캐릭터가 미니맵과 겹치면 바로 오른쪽 상단으로 가는 미니맵입니다~
---------------------------------------------------------------------------------
#==============================================================================
# 축소 맵의 표시(ver 0.999)
# by 데빌 clum-sea
#==============================================================================
#==============================================================================
# 캐스터 마이즈포인트
#==============================================================================
module PLAN_Map_Window
WIN_X = 8 # 윈도우의 X 좌표
WIN_Y = 350 # 윈도우의 Y 좌표
WIN_WIDTH = 4*32 # 윈도우의 폭
WIN_HEIGHT = 4*32 # 윈도우의 높이
ZOOM = 4.0 # 프의 축소율(32 * 32 의 타일을 몇분의 1으로 할까)
WINDOWSKIN = "" # 스킨(하늘에서 디폴트)
ON_OFF_KEY = Input::C # 윈도우의 온 오프를 바꾸는 버튼
SWITCH = 40 # 맵 윈도우 표시 금지용의 스윗치 번호
# (ON로 표시 금지, OFF로 표시 가능)
WINDOW_MOVE = true # 윈도우와 플레이어가 겹쳤을 시 자동적으로 이동할까
# (true:하는, false:하지 않는다)
OVER_X = 632 - WIN_WIDTH # 이동 후의 X 좌표(초기 위치와 왕복합니다)
OVER_Y = 8 # 이동 후의 Y 좌표(초기 위치와 왕복합니다)
OPACITY = 126 # 맵의 투명도
C_OPACITY = 192 # 윈도우의 투명도
VISIBLE = true # 최초, 표시할까 하지 않는가(true:하는, false:하지 않는다)
end
#==============================================================================
# ?? Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# ● 공개 인스턴스 변수
#--------------------------------------------------------------------------
attr_accessor :map_visible # ?맵 윈도우의 표시 상태
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
alias plan_map_window_initialize initialize
def initialize
# 되돌린다
plan_map_window_initialize
@map_visible = true
end
end
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# ● 메인 처리
#--------------------------------------------------------------------------
alias plan_map_window_main main
def main
# 윈도우를 작성
@map_window = Window_Map.new
@map_window.visible = $game_temp.map_visible
# 되돌린다
plan_map_window_main
# 메세지 윈도우를 해방
@map_window.dispose
end
#--------------------------------------------------------------------------
# ● 프레임 갱신
#--------------------------------------------------------------------------
alias plan_map_window_update update
def update
# visible 를 기억
$game_temp.map_visible = @map_window.visible
# 되돌린다
plan_map_window_update
# 금지가 아니면, 변환 처리
unless $game_switches[PLAN_Map_Window::SWITCH]
# 표시되고 있는 경우, 비표시로 한다
if Input.trigger?(PLAN_Map_Window::ON_OFF_KEY)
# 표시되어 있지 않은 경우, 표시한다
if @map_window.visible
@map_window.visible = true
# 표시되어 있지 않은 경우, 표시한다
else
@map_window.visible = true
end
end
# 금지의 경우는 강제적으로 비표시
else
if @map_window.visible
@map_window.visible = true
end
end
# 표시되고 있을 때만 갱신
if @map_window.visible
@map_window.update
end
end
#--------------------------------------------------------------------------
# ● 플레이어의 장소 이동
#--------------------------------------------------------------------------
alias plan_map_window_transfer_player transfer_player
def transfer_player
# visible 를 기억
visible = @map_window.visible
@map_window.visible = true
# 되돌린다
plan_map_window_transfer_player
# 맵 윈도우를 해방
@map_window.dispose
# 맵 윈도우를 작성
@map_window = Window_Map.new
# 표시 설정을 전맵 상태에 되돌린다
@map_window.visible = visible
end
end
#==============================================================================
# ■ Window_Map
#==============================================================================
class Window_Map < Window_Base
#--------------------------------------------------------------------------
# 타일 맵의 경우
#--------------------------------------------------------------------------
def initialize
x = PLAN_Map_Window::WIN_X
y = PLAN_Map_Window::WIN_Y
w = PLAN_Map_Window::WIN_WIDTH
h = PLAN_Map_Window::WIN_HEIGHT
super(x, y, w, h)
unless PLAN_Map_Window::WINDOWSKIN.empty?
self.windowskin = RPG::Cache.windowskin(PLAN_Map_Window::WINDOWSKIN)
end
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = PLAN_Map_Window::OPACITY
self.contents_opacity = PLAN_Map_Window::C_OPACITY
@map_data = $game_map.data
# ??C????b?v??????
@tileset = RPG::Cache.tileset($game_map.tileset_name)
@autotiles = []
for i in 0..6
autotile_name = $game_map.autotile_names[i]
@autotiles[i] = RPG::Cache.autotile(autotile_name)
end
# ???????v???C??????u???m??
@old_real_x = $game_player.real_x
@old_real_y = $game_player.real_y
# ??b?v???S?????????
@all_map = make_all_map
# ????E???????????
self.visible = PLAN_Map_Window::VISIBLE
# ???
refresh
end
#--------------------------------------------------------------------------
# ?? ??b?v???S??????????i?k???????t???j
#--------------------------------------------------------------------------
def make_all_map
all_map = Bitmap.new($game_map.width * 32, $game_map.height * 32)
for y in 0...$game_map.height
for x in 0...$game_map.width
for z in 0...3
tile_num = @map_data[x, y, z]
next if tile_num == nil
# ?I??g??C????????
if tile_num < 384
# ????C????????????????
if tile_num >= 48
tile_num -= 48
src_rect = Rect.new(32, 2 * 32, 32, 32)
all_map.blt(x * 32, y * 32, @autotiles[tile_num / 48], src_rect)
end
# 타일 맵의 경우
else
tile_num -= 384
src_rect = Rect.new(tile_num % 8 * 32, tile_num / 8 * 32, 32, 32)
all_map.blt(x * 32, y * 32, @tileset, src_rect)
end
end
end
end
# 전체 맵으로부터 축소 맵에
w = ($game_map.width / PLAN_Map_Window::ZOOM) * 32
h = ($game_map.height / PLAN_Map_Window::ZOOM) * 32
ret_bitmap = Bitmap.new(w, h)
src_rect = Rect.new(0, 0, all_map.width, all_map.height)
dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
ret_bitmap.stretch_blt(dest_rect, all_map, src_rect)
all_map.dispose
return ret_bitmap
end
#--------------------------------------------------------------------------
# ● 리프레쉬
#--------------------------------------------------------------------------
def refresh
self.contents.clear
# 축소 맵 표시
one_tile_size = 32 / PLAN_Map_Window::ZOOM
x = $game_player.real_x - 128 * (self.contents.width / one_tile_size) / 2
y = $game_player.real_y - 128 * (self.contents.height / one_tile_size) / 2
x = x * one_tile_size / 128
y = y * one_tile_size / 128
# 스크롤 스톱 처리(옆)
# 캐릭터의 위치(contents 의 중앙)
half_width = self.contents.width * 128 / 2
# 캐릭터의 위치(실위치)~맵의 구석까지의 나머지폭
rest_width = ($game_map.width * 128 - $game_player.real_x) * one_tile_size
# 윈도우보다 맵의 폭이 작으면
rev_x = 0
# 맵이 윈도우보다 작은 경우는 중앙 표시
if @all_map.width < self.contents.width
rev_x = (half_width - $game_player.real_x * one_tile_size) / 128
rev_x -= (self.contents.width - @all_map.width) / 2
x += rev_x
# ??????b?v?????????????
elsif half_width > $game_player.real_x * one_tile_size
rev_x = (half_width - $game_player.real_x * one_tile_size) / 128
x += rev_x
# 오른쪽이 맵의 구석을 넘으면
elsif half_width > rest_width
rev_x = -((half_width - rest_width) / 128)
x += rev_x
end
# 스크롤 스톱 처리(세로)
# 캐릭터의 정도 치(contents 의 중앙)
half_height = self.contents.height * 128 / 2
# 캐릭터의 위치(실위치)~맵의 구석까지의 나머지 높이
rest_height = ($game_map.height * 128 - $game_player.real_y) * one_tile_size
# 윈도우보다 맵의 폭이 작으면
rev_y = 0
# 맵이 윈도우보다 작은 경우는 중앙 표시
if @all_map.height < self.contents.height
rev_y = (half_height - $game_player.real_y * one_tile_size) / 128
rev_y -= (self.contents.height - @all_map.height) / 2
y += rev_y
# 오른쪽이 맵의 구석을 넘으면
elsif half_height > $game_player.real_y * one_tile_size
rev_y = (half_height - $game_player.real_y * one_tile_size) / 128
y += rev_y
# ?E????b?v?????????????
elsif half_height > rest_height
rev_y = -((half_height - rest_height) / 128)
y += rev_y
end
src_rect = Rect.new(x, y, self.contents.width, self.contents.height)
self.contents.blt(0, 0, @all_map, src_rect)
# 윈도우의 이동 처리
if PLAN_Map_Window::WINDOW_MOVE == true
# 윈도우의 범위를 취득(범위 오브젝트)
w = self.x..self.x + self.width
h = self.y..self.y + self.height
# 플레이어가 윈도우의 범위내에 들어갔을 경우
if w === $game_player.screen_x and h === $game_player.screen_y
# 이동 장소 판정
# 초기 위치라면
if self.x == PLAN_Map_Window::WIN_X and self.y == PLAN_Map_Window::WIN_Y
# 이동 후의 좌표에 이동
self.x = PLAN_Map_Window::OVER_X
self.y = PLAN_Map_Window::OVER_Y
# 초기 위치가 아닌 경우
else
# 초기 위치에 이동
self.x = PLAN_Map_Window::WIN_X
self.y = PLAN_Map_Window::WIN_Y
end
end
end
# 액터가 있는 경우는 최초의 액터를 맵에 표시
if $game_party.actors.size > 0
# priority 체크 숨는다면 액터비표시
for i in [2, 1, 0]
tile = @map_data[$game_player.x, $game_player.y, i]
next if tile == 0
return if $game_map.priorities[tile] > 0
end
actor = $game_party.actors[0]
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
width = bitmap.width / 4
height = bitmap.height / 4
src_rect = Rect.new(0, 0, width, height)
# 액터를 중앙에 표시
w = width / PLAN_Map_Window::ZOOM
h = height / PLAN_Map_Window::ZOOM
# 타일의 폭만 짝수이므로 반타일분 늦춘다
x = self.contents.width / 2 - w / 2 + one_tile_size / 2 - rev_x
y = self.contents.height / 2 - h / 2 - rev_y
dest_rect = Rect.new(x, y, w, h)
self.contents.stretch_blt(dest_rect, bitmap, src_rect)
end
end
#--------------------------------------------------------------------------
# ● 프레임 갱신
#--------------------------------------------------------------------------
def update
super
if @old_real_x != $game_player.real_x or @old_real_y != $game_player.real_y
@old_real_x = $game_player.real_x
@old_real_y = $game_player.real_y
refresh
end
end
#--------------------------------------------------------------------------
# ● 해방
#--------------------------------------------------------------------------
def dispose
super
@all_map.dispose
end
end
출처 : 십자군RPG카페
이 스크립트를 메인 위에 넣으세요
댓글 11
-
아란
2006.09.08 04:59
-
헨젤
2006.10.11 00:36
오옷 +_+ 시간되면 만들어볼까나..??|+rp2+|2351|+rp3+|acoc_board_ideatip -
아웅짜잉나
2006.12.31 05:59
오오 -_-|+rp2+|2572|+rp3+|acoc_board_ideatip -
rpgxp폐인
2007.01.07 00:30
해봐야지...|+rp2+|2607|+rp3+|acoc_board_ideatip -
싸이케데스
2007.02.01 17:11
문제가 있습니다.
원래 미니맵은 주위를 미리 볼 수 있어야 하는데..
이건 그냥 화면의 축소판이 아닙니까? [...] 오히려 보통 화면보다 시야가 좁은듯...
아쉬운데 어떻게 안될지 <-스크립트는 스자도 안해봤다|+rp2+|2747|+rp3+|acoc_board_ideatip -
asdfww
2007.02.24 22:38
zoom = 4.0 을 10.0정도로 바꾸면 시야가 더 넓어진답니다~|+rp2+|2805|+rp3+|acoc_board_ideatip -
asdfww
2007.02.24 22:38
ZOOM = 4.0 # 프의 축소율(32 * 32 의 타일을 몇분의 1으로 할까) - 이부분 말하는 거입니다.|+rp2+|2806|+rp3+|acoc_board_ideatip -
협객
2007.06.11 06:18
항구 지도 시스템 매우 쉽게 완성. ㅡ.ㅡ;;;|+rp2+|2964|+rp3+|acoc_board_ideatip -
협객
2007.06.11 06:21
맵을 그림으로 변환할 수 있다면, 역으로 그림을 맵 타일 세트로 변환하는 것도 가능하지 않을까요?
예를 들어서 세계지도 그림 파일이 있으면, 그 그림을 세계지도 맵으로 변환하는 것도 가능하지 않을까 생각합니다.|+rp2+|2965|+rp3+|acoc_board_ideatip -
RPG액알
2007.06.18 00:27
저는 이거 그대로 복사해서 붙여썻는데? 그렇게 하면안되나요? 76번 항목이 name error 가 있다더군요...
안데나요??/ 여기서는 메인처리 밑에 alias plan_map_window_main main 거기군요 이걸 어떻게 바꿔야하나요??|+rp2+|2972|+rp3+|acoc_board_ideatip -
영혼의그림자
2008.02.19 03:30
오오오오오 ㅂ= 흥미진지합니다|+rp2+|3221|+rp3+|acoc_board_ideatip
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
469 | 게이지바 스크립트 [6] | 브레인 | 2006.09.06 | 4371 |
468 | [MiD]비전투RPG -1- [2] | 천공MiD짱 | 2006.05.17 | 3211 |
467 | 연애 시뮬레이션 만들기 2 [11] | Vermond | 2006.07.26 | 3082 |
466 | 신개념 마법시스템? [16] | [S's-S] | 2006.07.25 | 2856 |
465 | 게임에서 마우스로 게임하기 [10] | 브레인 | 2006.09.06 | 2472 |
464 | SRPG 만들기 강의 - 0. SRPG는 무엇일까? [6] | contect | 2008.07.23 | 2392 |
463 | RPG 2000/2003에서의 마우스 사용(수정) [14] | Black-☆ | 2007.11.19 | 2132 |
» | 미니맵을 만들어 보자 - 스크립트 - [11] | 브레인 | 2006.09.06 | 1922 |
461 | [VX] 창문으로 빛이 뚫고 나오게 하기 [뽀샵] [2] | 정의로운녀석! | 2008.06.22 | 1875 |
460 | rpg만들기 DS 사용법(60%) [4] | GMF | 2007.12.28 | 1819 |
459 | 인벤토리 시스템 [내용 또 수정] [17] | 비밀소년 | 2006.07.28 | 1800 |
458 | RPG만들기 실력테스트! [16] | 엔젤레기온 | 2007.12.18 | 1792 |
457 | 악당들의 유형들..? [23] | 크레시스 | 2005.12.27 | 1767 |
456 | RPG_xp업그레이드 팩키지 [3] | 星の카비 | 2007.12.16 | 1764 |
455 | [TIP]대기 0초 [19] | Yggdrasil | 2006.08.11 | 1763 |
454 | 보스는 왜 맨날 쫄자들만 보내는가!? [23] | 다크아머 | 2006.01.23 | 1674 |
453 | 바람의나라 - 쇄혼비무 , 초혼비무 [9] | 액알의초보 | 2006.07.04 | 1672 |
452 | [THDO]판화 세계지도제작 스크립트. [7] | 협객 | 2007.06.25 | 1668 |
451 | 콤보 스크립트 [7] | 귀여븐닌자 | 2006.08.23 | 1624 |
450 | [공개자료] 먼치킨 액알 만들기 [11] | 책벌레공상가 | 2007.03.26 | 1598 |
어쨌든 감사합니다.|+rp2+|2280|+rp3+|acoc_board_ideatip