조회 수 435 추천 수 1 댓글 0
Atachment
첨부 '2'
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄





#==============================================================================
# ■ 오토 매핑
#------------------------------------------------------------------------------
# ver 1.00(05/04/27) by 상입오두막 http://aea.to/hako/
#====================================================================== ========
=begin
■ 주로 사용하는 메소드

automaps[id] : id 차례의 오토 맵을 참조.

visible : 진정한이라고 해 표시.
scope : 묘화 범위.
complete : 모두 통행 한 상태로 한다.
delete : 통행 기록을 지운다.
move(x,y[,center]) : (x,y)에 이동.center가 진정한이라고 해 원점 중심.

이벤트 커멘드 「스크립트」로의 기술예입니다.


automaps[0].scope = 0
automaps[0].visible = true

현재 있는 맵의 오토 맵(작성중의 것)을 표시합니다.
scope 에 0을 대입하면, 플레이어가 다닌 위치만이 통행이 끝난 상태로 판정됩니다.

automaps[0].visible = false

현재 있는 맵의 오토 맵을 비표시로 합니다.

(이벤트 커멘드 「스크립트」로 위와 같은 문장을 쓰면, 디폴트에서는 잘 동작하지 않습니다.
「스크립트」의 1행째에 가짜를 돌려주는 처리를 쓰면 멈추어 버리기 (위해)때문입니다.(아마 XP의 버그입니다)
이것을 회피하기 위해서, 클래스 Interpreter를 수정하는지, 1행째는 공행 등에 할 필요가 있습니다.)



automaps[0].move(320, 240, true)
automaps[0].complete
automaps[0].visible = true
현재 있는 맵의 완성한 상태의 오토 맵을 화면의 중심으로 표시합니다.


automaps[2].visible = true

2번의 맵의 오토 맵을 표시합니다. 플레이어가 통행 한 기록은 다른 맵으로 이동해도 보관 유지되므로, 이전 만든 채로의 오토 맵이 표시됩니다.

=end

class Game_AutoMap
#--------------------------------------------------------------------------
# ● 정수
#--------------------------------------------------------------------------
# 오토 맵의 작성을 허가하는 맵 ID의 배열
AUTOMAPS_ID = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
# 1 타일 근처의 한 변의 길이(pixel 단위)
TILE_SIZE = 5
# 통행이 끝난 상태라고 판단되는 범위의 크기(타일 단위)
SCOPE = 0
end

class Sprite_AutoMap < Sprite
#--------------------------------------------------------------------------
# ● 정수
#--------------------------------------------------------------------------
# ※불투명도(알파치)를 0으로 하면 무효가 됩니다.
#-----------------------------------------------
# 통행이 끝난 에리어의 색(Red, Green, Blue[, Alpha])
COLOR_FLOOR = Color.new(100, 100, 255, 120)
# 미통행/통행 불가의 에리어의 색
COLOR_WALL = Color.new(0, 0, 50, 100)
# 플레이어 심볼의 색
COLOR_PLAYER = Color.new(255, 255, 0, 255)
#------------------------------ -----------------
# 통행이 끝난 에리어에 붙이는 픽쳐 파일, 불투명도
PASSED_FILE = ["filename", 0]
# 미통행/통행 불가 에리어에 붙이는 픽쳐 파일, 불투명도
IMPASSABLE_FILE = ["filename", 0]
# 플레이어 심볼로서 표시하는 픽쳐 파일, 불투명도
PLAYER_FILE = ["filename", 0]
end

#================================================================ ==============
# ■ Interpreter
#==============================================================================
class Interpreter
#--------------------------------------------------------------------------
# ● 오토 맵의 데이터를 취득
#---------------------------------------------------------------- ----------
def automaps
$game_screen.automaps
end
end

#==============================================================================
# ■ Game_Screen
#==============================================================================
class Game_Screen
attr_accessor :automaps # Game_AutoMap 오브젝트를 격납하는 Hash
alias automapping_100_initialize initialize
def initialize
@automaps = {}
automapping_100_initialize
end
end

#==============================================================================
# ■ Game_AutoMap
#=========================================== ===================================
class Game_AutoMap
attr_accessor :player_pos # 플레이어 좌표
attr_accessor :showing # 오토 맵 표시 플래그
attr_accessor :scope # 묘화 범위(플레이어로부터의 거리)
attr_accessor :recording # 오토 맵 기록 개시 플래그
attr_reader :calling # 외부 오토 맵 호출 플래그
attr_reader :drawn_floor # 오토 맵의 묘화 정보
attr_reader :x # 표시 위치 x
attr_reader :y # 표시 위치 y
attr_reader :tile_size # 타일의 크기
attr_reader :width # 맵의 폭
attr_reader :height # 맵의 높이
attr_reader :passable # 통행 가능 좌표
attr_reader :id # 맵의 ID
attr_reader :name # 맵의 이름
attr_reader :permission # 오토 맵 작성 허가 플래그
#--------------------------------------------------------------------------
# ● 오브젝트 초기화(새로운 맵으로 이동했을 때 실행)
#--------------------------------------------------------------------------
def initialize
@permission = AUTOMAPS_ID.include?($game_map.map_id)
return if not @permission
@recording = false
@showing = false
@calling = false
@player_pos = [-1, -1]
@drawn_floor = Table.new($game_map.width, $game_map.height)
@x = 0
@y = 0
@scope = SCOPE
@tile_size = TILE_SIZE
@width = $game_map.width
@height = $game_map.height
@passable = Table.new(@width, @height)
for x in 0..@width
for y in 0..@height
if $game_map.passable?(x, y, 0)
@passable[x, y] = 1 # 통행 가능하면 1
end
end
end
@id = $game_map.map_id
mapinfo = load_data("Data/MapInfos.rxdata") # RPG::MapInfo(Hash, key:id)
@name = mapinfo[$game_map.map_id].name.dup
end
#--------------------------------------------------------------------------
# ● 오토 맵의 기록 개시
#--------------------------------- -----------------------------------------
def setup
@calling = false
@player_pos = [-1, -1]
@recording = true
return true
end
#--------------------------------------------------------------------------
# ● 오토 맵의 표시/비표시
#------------------------------------------- -------------------------------
def visible
return @showing
end
def visible=(visible)
@calling = (@id != $game_map.map_id)
@recording = true
@player_pos = [-1, -1]
@showing = visible
end
#------------------------------------------------------------------------ --
# ● 오토 맵의 완성
#--------------------------------------------------------------------------
def complete
for x in 0..@width
for y in 0..@height
@drawn_floor[x, y] = 1 if @passable[x, y] == 1
end
end
return true
end
#------------------------------ --------------------------------------------
# ● 오토 맵의 소거
#--------------------------------------------------------------------------
def delete
for x in 0..@width
for y in 0..@height
@drawn_floor[x, y] = 0
end
end
@showing = false
@player_pos = [ -1, -1]
@calling = false
return true
end
#--------------------------------------------------------------------------
# ● 오토 맵의 이동
#--------------------------------------------------------------------------
def move(x, y, center = false)
if center
@x = (640 - @width * @tile_size) / 2
@y = (480 - @height * @tile_size) / 2
else
@x = x
@y = y
end
return true
end
end

#==============================================================================
# ■ Spriteset_Map
#==================================================== ==========================
class Spriteset_Map
alias automapping_100_initialize initialize
def initialize
amaps = $game_screen.automaps
# 현재의 맵의 오토 맵이 존재하지 않는다
if not amaps.include?($game_map.map_id)
# 맵 ID를 키로서 Game_AutoMap 오브젝트를 생성
amaps[$game_map.map_id] = Game_AutoMap.new
# 오토 맵의 작성이 허가되어 있지 않은 경우
if not amaps[$game_map.map_id].permission
amaps.delete($game_map.map_id)
end
end
if amaps.include?($game_map.map_id)
# 0번에 현재의 맵을 관련짓는다
amaps.delete(0)
amaps[0] = amaps[$game_map.map_id]
# 플레이어 위치의 기록을 개시
amaps[$game_map.map_id].setup
end
@viewport_automap = Viewport.new(0, 0, 640, 480)
@viewport_automap.z = 198 # 오토 맵의 Z좌표
@automap_sprites = []
# 지금까지 작성된 모든 오토 맵의 스프라이트 생성
for map_id in amaps.keys
next if map_id == 0
@automap_sprites << Sprite_AutoMap.new(@viewport_automap, amaps[map_id])
end
automapping_100_initialize
end
alias automapping_100_dispose dispose
def dispose
for sprite in @automap_sprites
sprite.dispose
end
automapping_100_dispose
@viewport_automap.dispose
end
alias automapping_100_update update
def update
for sprite in @automap_sprites
sprite.update
end
automapping_100_update
@viewport_automap.update
end
end

#==============================================================================
# ■ Sprite_AutoMap
#================== ============================================================
class Sprite_AutoMap < Sprite
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
# viewport :뷰포트, automap :Game_AutoMap
#------------------------------------------------------------ --------------
def initialize(viewport, automap)
super(viewport)
@automap = automap
w = @automap.width * @automap.tile_size
h = @automap.height * @automap.tile_size
self.bitmap = Bitmap.new(w, h)
# 전송용의 구형
@rect = Rect.new(0, 0, 0, 0)
# 오토 맵의 화상
if PASSED_FILE[1] > 0
@floor_bitmap = RPG::Cache.picture(PASSED_FILE[0])
end
if IMPASSABLE_FILE[1] > 0
@wall_bitmap = RPG::Cache.picture(IMPASSABLE_FILE[0])
end
# 플레이어 심볼 묘화
@player_symbol = Sprite.new(viewport)
if PLAYER_FILE[1] > 0
@player_symbol.bitma p = RPG::Cache.picture(PLAYER_FILE[0])
@player_symbol.ox=(@player_symbol.bitmap.width - @automap.tile_size)/2
@player_symbol.oy = @player_symbol.bitmap.height / 2
@player_symbol.visible = false
else
@player_symbol.bitmap = Bitmap.new(w, h)
end
update
end
#--------------------------------------------------------------------------
# ● 프레임 갱신
#--------------------------------------------------------------------------
def update
if not @automap.recording
return
end
# 플레이어의 위치가 같은(이동하고 있지 않다) 경우
if @automap.player_pos == [$game_player.x, $game_player.y]
return
end
self.x = @player_symbol.x = @automap.x
self.y = @player_symbol.y = @automap.y
self.visible = @player_symbol.visible = @automap.showing
@automap.player_pos = [$game_player.x, $game_player.y]
len = @automap.tile_size
# 별맵으로부터의 호출의 경우
if @automap.calling
# 통행이 끝난 에리어 묘화
if PASSED_FILE[1] > 0
draw_passable_picture(len)
elsif COLOR_FLOOR.alpha > 0
draw_passable(len)
end
# 미통행/통행 불가 에리어 묘화
if IMPASSABLE_FILE[1] > 0
draw_impassable_picture(len)
elsif COLOR_WALL.alpha > 0
draw_impassable(len)
end
return
end
# 묘화 범위 취득
x_min = [0, $game_player.x - @automap.scope].max
x_max = [@automap.width, $game_player.x + @automap.scope].min
y_min = [0, $game_player.y - @automap.scope].max
y_max = [@automap.height, $game_player.y + @automap.scope].min
for x in x_min..x_max
for y in y_min..y_max
# 미통행 and 통행 가능
if @automap.drawn_floor[x, y] == 0 and @automap.passable[x, y] == 1
# 그 좌표를 보존
@automap.drawn_floor[x, y] = 1
end
end
end
if @automap.showing
self.bitmap.clear
# 통행이 끝난 에리어 묘화
if PASSED_FILE[1] > 0
draw_passable_picture(len)
elsif COLOR_FLOOR.alpha > 0
draw_passable(len)
end
# 미통행/통행 불가 에리어 묘화
if IMPASSABLE_FILE[1] > 0
draw_impassable_picture(len)
elsif COLOR_WALL.alpha > 0
draw_impassable(len)
end
# 플레이어 심볼 갱신
if PLAYER_FILE[1] > 0 or COLOR_PLAYER.alpha > 0
player_symbol_update
end
end
end
#--------------------------------------------------------------------------
# ● 통행 에리어 묘화
#--------------------------------------------------------------------------
def draw_passable(len)
for x in 0..@automap.width
for y in 0..@automap.height
# 보존된 좌표가 1 의 경우
if @automap.drawn_floor[x, y] == 1
# 타일 묘화
self.bitmap.fill_rect(x*len, y*len, len, len, COLOR_FLOOR)
end
end
end
end
#--------------------------------------------------------------------------
# ● 통행 에리어(픽쳐) 묘화
#--------------------------------------------------------------------------
def draw_passable_picture(len)
for x in 0..@automap.width
for y in 0..@automap.height
# 보존된 좌표가 1 의 경우
if @automap.drawn_floor[x, y] == 1
@rect.set((x*len) %@floor_bitmap.width, (y*len) %@floor_bitmap.height,
len, len)
# 타일 묘화
self.bitmap.blt(x*len, y*len,
@floor_bitmap, @rect, PASSED_FILE[1])
end
end
end
end
#--------------------------------------------------------------------------
# ● 미통행/통행 불가 에리어 묘화
#--------------------------------------------------------------------------
def draw_impassable(len)
for x in 0..@automap.width
for y in 0..@automap.height
# 보존된 좌표가 0 의 경우
if @automap.drawn_floor[x, y] == 0
# 타일 묘화
self.bitmap.fill_rect(x*len, y*len, len, len, COLOR_WALL)
end
end
end
end
#------------------------------- -------------------------------------------
# ● 미통행/통행 불가 에리어(픽쳐) 묘화
#--------------------------------------------------------------------------
def draw_impassable_picture(len)
for x in 0..@automap.width
for y in 0..@automap.height
# 보존된 좌표가 0 의 경우
if @automap. drawn_floor[x, y] == 0
@rect.set((x*len) %@wall_bitmap.width, (y*len) %@wall_bitmap.height,
len, len)
# 타일 묘화
self.bitmap.blt(x*len, y*len, @wall_bitmap, @rect, IMPASSABLE_FILE[1])
end
end
end
end
#----------------------- ---------------------------------------------------
# ● 플레이어 심볼 갱신
#--------------------------------------------------------------------------
def player_symbol_update
len = @automap.tile_size
x = $game_player.x * len
y = $game_player.y * len
# 픽쳐
if PLAYER_FILE[ 1] > 0
@player_symbol.x += x
@player_symbol.y += y
@player_symbol.opacity = PLAYER_FILE[1]
else
@player_symbol.bitmap.clear
@player_symbol.bitmap.fill_rect(x, y, len, len, COLOR_PLAYER)
end
end
#------------------------------------------------------ --------------------
# ● 해방
#--------------------------------------------------------------------------
def dispose
if self.bitmap != nil
# 다른 맵으로 이동했을 경우는 비표시로 한다
if $scene.is_a?(Scene_Map)
@automap.showing = false
@automap.recording = false
end
@automap.player_pos = [-1, -1]
self.bitmap.dispose
self.bitmap = nil
@player_symbol.bitmap.dispose
@player_symbol.bitmap = nil
end
super
end
end


?

  1. 쯔꾸르 mv 게임을 apk 파일로 변환했는데...

    Date2023.01.14 By박하맛 Views1330
    Read More
  2. 쯔꾸르 젖소이야기 결혼 방법좀 알려주세요...

    Date2021.12.20 By백지씨 Views2627
    Read More
  3. apk포팅 승인 어케 하나요?

    Date2021.11.29 Bygame메이커xp Views1257
    Read More
  4. Yanfly님의 Action Sequence Pack 질문드립니다

    Date2021.07.15 ByNeuromancer Views1541
    Read More
  5. 싸게 MV 를 먼저? 아니면 돈을 더 들어서라도 MZ?

    Date2021.07.06 ByXatra Views1752
    Read More
  6. RMMV - 스탯창과 대화창 변견 관련 질문입니다. (초보입니다 도움좀 주세요 ㅜㅜ)

    Date2021.01.22 Byscribble Views1553
    Read More
  7. 아오오니를 하는 사람인데요 질문 두가지가 있어요

    Date2021.01.16 By오니개무서워 Views1634
    Read More
  8. 재밌는게임

    Date2020.12.07 Byland_tnt Views1455
    Read More
  9. c언어 질문

    Date2020.11.10 By세종기항19 Views1684
    Read More
  10. 코딩 질문

    Date2020.11.08 By세종기항19 Views1539
    Read More
  11. 혹시나 물어보는데

    Date2020.11.07 By드래곤규 Views1402
    Read More
  12. 오픈보 게임 더블드래곤 리로디드 얼티네이트에 대해 궁금

    Date2020.09.09 By이부닝 Views1224
    Read More
  13. 상태이상 확률 결정

    Date2020.09.02 By스트레이보우 Views1006
    Read More
  14. 다음 인디사이드 제작대회는 언제쯤 열릴까요?

    Date2020.05.23 ByWOONAALAA Views963
    Read More
  15. xp로 제작된 어플 실행자체가 안된다는 분이 있습니다.(제생각엔 apk로 변환하는 과정에서 버전자체가 낮은 것 같습니다)

    Date2020.05.04 By라엔 Views1415
    Read More
  16. apk 포팅하는데 게임 이름이 필요합니다 뜨는데

    Date2020.05.03 Bykashu Views1350
    Read More
  17. 쯔꾸르VX Ace렉먹음 도와주세요...

    Date2020.03.22 By랖랖 Views1780
    Read More
  18. 안녕하세요

    Date2020.02.14 By청월령 Views834
    Read More
  19. 포팅 중 '게임 이름이 필요합니다' 오류

    Date2020.02.11 By아이비스 Views817
    Read More
  20. RPGMV 거리 추적

    Date2020.01.19 By정욱 Views931
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 442 Next
/ 442


[개인정보취급방침] | [이용약관] | [제휴문의] | [후원창구] | [인디사이드연혁]

Copyright © 1999 - 2016 INdiSide.com/(주)씨엘쓰리디 All Rights Reserved.
인디사이드 운영자 : 천무(이지선) | kernys(김원배) | 사신지(김병국)