XP 스크립트

http://www.dubealex.com/asylum/index.php?showtopic=10127

뒤섞인 퍼즐을 순서대로 다시 맞추는 미니게임입니다. 일단 사용법은 데모를 참조하세요.




#==============================================================================
# ** Shift Puzzles
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1
# 2006-07-23
#------------------------------------------------------------------------------
# * Instructions:
#
# ~ To Customize Your Script-x Puzzle, find the line with:
# Game_ShiftPuzzle.new
# ~ After new, add
# (width, height, image)
# width : number of tiles wide
# height : number of tiles high
# image : picture in Graphics/Pictures/Shift Puzzles
#
# ~ To Open Shift Puzzle Game, use
# $scene.open_shiftpuzzle
#
# ~ To Check if Shift Puzzle is Finished, used a Script-x Conditional Branch
# $game_shiftpuzzle.has_won?
#
# ~ To Reset the Puzzle, use:
# $game_shiftpuzzle = Game_ShiftPuzzle.new
#------------------------------------------------------------------------------
# * Customization:
#
# ~ Show Tile Numbers Automatically:
# Show_Tile_Numbers = true (On) or false (Off)
# ~ Show Tile Borders Automatically:
# Show_Tile_Borders = true (On) or false (Off)
# ~ Tile Number Color:
# Tile_Number_Color = Color.new(r, g, b, a)
# ~ Tile Border Color:
# Tile_Border_Color = Color.new(r, g, b, a)
# ~ Solved SE
# Puzzle_Solved_SE = RPG::AudioFile
# ~ Unsolved SE
# Puzzle_Unsolved_SE = RPG::AudioFile
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script-x
#------------------------------------------------------------------------------
SDK.log('Shift Puzzles', 'SephirothSpawn', 1, '2006-07-23')

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Shift Puzzles') == true

#==============================================================================
# ** Game_ShiftPuzzle
#==============================================================================

class Game_ShiftPuzzle
#--------------------------------------------------------------------------
# * Customizable Options
#--------------------------------------------------------------------------
Show_Tile_Numbers = true
Show_Tile_Borders = true
Tile_Number_Color = Color.new(0, 0, 0)
Tile_Border_Color = Color.new(255, 255, 255)
Puzzle_Solved_SE = load_data("Data/System.rxdata").decision_se
Puzzle_Unsolved_SE = load_data("Data/System.rxdata").buzzer_se
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :width
attr_reader :height
attr_reader :image
attr_reader :cursor
attr_reader :data
attr_reader :moves
attr_reader :tile_width
attr_reader :tile_height
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(width = 5, height = 5, image = 'Sample')
# Sets Puzzle Parameters
@width = width
@height = height
@image = RPG::Cache.picture("Shift Puzzles/#{image}")
# Gets Tile Dimensions
@tile_width = @image.width / @width
@tile_height = @image.height / @height
# Sets Up Data Table
@data = Table.new(width, height)
setup_table
# Starts Move Counter
@moves = 0
end
#--------------------------------------------------------------------------
# * Setup Table
#--------------------------------------------------------------------------
def setup_table
range = (0...(@width * @height)).to_a
for x in 0...@width
for y in 0...@height
@data[x, y] = range[index = rand(range.size)]
range.delete_at(index)
if @data[x, y] == (@width * @height) - 1
@cursor_x = x
@cursor_y = y
end
end
end
end
#--------------------------------------------------------------------------
# * Move Right
#--------------------------------------------------------------------------
def move_right
# If Far Right Tile
if @cursor_x == @width - 1
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# Switches Data
@data[@cursor_x, @cursor_y] = @data[@cursor_x + 1, @cursor_y]
@data[@cursor_x + 1, @cursor_y] = (@width * @height) - 1
# Adds to Cursor
@cursor_x += 1
# Adds to Move Counter
@moves += 1
end
#--------------------------------------------------------------------------
# * Move Left
#--------------------------------------------------------------------------
def move_left
# If Far Left Tile
if @cursor_x == 0
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# Switches Data
@data[@cursor_x, @cursor_y] = @data[@cursor_x - 1, @cursor_y]
@data[@cursor_x - 1, @cursor_y] = (@width * @height) - 1
# Adds to Cursor
@cursor_x -= 1
# Adds to Move Counter
@moves += 1
end
#--------------------------------------------------------------------------
# * Move Up
#--------------------------------------------------------------------------
def move_up
# If Upper Tile
if @cursor_y == 0
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# Switches Data
@data[@cursor_x, @cursor_y] = @data[@cursor_x, @cursor_y - 1]
@data[@cursor_x, @cursor_y - 1] = (@width * @height) - 1
# Adds to Cursor
@cursor_y -= 1
# Adds to Move Counter
@moves += 1
end
#--------------------------------------------------------------------------
# * Move Down
#--------------------------------------------------------------------------
def move_down
# If Lower Tile
if @cursor_y == @height - 1
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# Switches Data
@data[@cursor_x, @cursor_y] = @data[@cursor_x, @cursor_y + 1]
@data[@cursor_x, @cursor_y + 1] = (@width * @height) - 1
# Adds to Cursor
@cursor_y += 1
# Adds to Move Counter
@moves += 1
end
#--------------------------------------------------------------------------
# * Tile Image
#--------------------------------------------------------------------------
def tile_image(x, y)
# Gets Data Tile
tile_n = @data[x, y]
# Reconfigure X and Y
x = tile_n % @width
y = tile_n / @height
# Creates Blank Bitmap
bitmap = Bitmap.new(@tile_width, @tile_height)
# Transfers Section of Bitmap onto Blank Bitmap
bitmap.blt(0, 0, @image, Rect.new(x * @tile_width, y * @tile_height,
@tile_width, @tile_height))
# Show Tile Numbers
if Show_Tile_Numbers
bitmap.font.color = Tile_Number_Color
bitmap.draw_text(0, 0, @tile_width, @tile_height, (tile_n + 1).to_s, 1)
end
# Show Tile Border
if Show_Tile_Borders
bitmap.fill_rect(0, 0, @tile_width, 1, Tile_Border_Color)
bitmap.fill_rect(0, @tile_height - 1, @tile_width, 1, Tile_Border_Color)
bitmap.fill_rect(0, 0, 1, @tile_height, Tile_Border_Color)
bitmap.fill_rect(@tile_width - 1, 0, 1, @tile_height, Tile_Border_Color)
end
# Returns Bitmap
return bitmap
end
#--------------------------------------------------------------------------
# * Has Won Test
#--------------------------------------------------------------------------
def has_won?
for i in 0...@width
for j in 0...@height
unless @data[i, j] == j * height + i
return false
end
end
end
return true
end
end

#==============================================================================
# ** Window_ShiftPuzzle
#==============================================================================

class Window_ShiftPuzzle < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(puzzle = $game_shiftpuzzle)
super(0, 0, puzzle.image.width + 32, puzzle.image.height + 80)
self.contents = Bitmap.new(width - 32, height - 32)
@puzzle = puzzle
@active = true
# Sets Up Coordinates
self.x = 320 - self.width / 2
self.y = 240 - self.height / 2
# Sets Up Image
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
# Draws Every Tile
for x in 0...@puzzle.width
for y in 0...@puzzle.height
self.contents.blt(x * @puzzle.tile_width, y * @puzzle.tile_height,
@puzzle.tile_image(x, y), Rect.new(0, 0,
@puzzle.tile_width, @puzzle.tile_height))
end
end
refresh_score
end
#--------------------------------------------------------------------------
# * Refresh Score
#--------------------------------------------------------------------------
def refresh_score
# Clears Old Area
self.contents.fill_rect(0, @puzzle.image.height, contents.width, 48,
Color.new(0, 0, 0, 0))
# Draws Status & Moves Words
self.contents.font.color = system_color
self.contents.draw_text(0, y = @puzzle.image.height, contents.width, 24,
@puzzle.has_won? ? 'You Win' : 'Keep Trying...', 1)
self.contents.draw_text(4, y + 24, contents.width, 24, 'Moves:')
self.contents.font.color = normal_color
self.contents.draw_text(- 4, y + 24, contents.width, 24,
@puzzle.moves.to_s, 2)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# If Active
if @active
# If Right is Pressed
if Input.trigger?(Input::RIGHT)
@puzzle.move_right
refresh
# If Left is Pressed
elsif Input.trigger?(Input::LEFT)
@puzzle.move_left
refresh
# If Up is Pressed
elsif Input.trigger?(Input::UP)
@puzzle.move_up
refresh
# If Down is Pressed
elsif Input.trigger?(Input::DOWN)
@puzzle.move_down
refresh
end
end
end
end

#==============================================================================
# ** Scene_Map
#==============================================================================

class Scene_Map
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_shiftpuzzles_scnmap_update update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# If Shift Puzzle Active
unless @seph_shiftpuzzle_window.nil?
update_seph_shiftpuzzle
return
end
# Original Update
seph_shiftpuzzles_scnmap_update
end
#--------------------------------------------------------------------------
# * Frame Update : Seph Shift Puzzle
#--------------------------------------------------------------------------
def update_seph_shiftpuzzle
# Update Shift Puzzle Window
@seph_shiftpuzzle_window.update
# Update Map and Spriteset
$game_map.update
$game_system.map_interpreter.update
$game_system.update
$game_screen.update
@spriteset.update
@message_window.update
# If C Button is Pressed
if Input.trigger?(Input::C)
# If Puzzle Solved
if $game_shiftpuzzle.has_won?
# Play Solved SE
$game_system.se_play(Game_ShiftPuzzle::Puzzle_Solved_SE)
else
# Play Unsolved SE
$game_system.se_play(Game_ShiftPuzzle::Puzzle_Unsolved_SE)
end
# Dispose Window
@seph_shiftpuzzle_window.dispose
end
end
#--------------------------------------------------------------------------
# * Open Shift Puzzle
#--------------------------------------------------------------------------
def open_shiftpuzzle
# Creates Shift Puzzle Window
@seph_shiftpuzzle_window = Window_ShiftPuzzle.new
end
end

#==============================================================================
# ** Scene_Title
#==============================================================================

class Scene_Title
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_shiftpuzzles_scnttl_cng command_new_game
#--------------------------------------------------------------------------
# * Command : New Game
#--------------------------------------------------------------------------
def command_new_game
# Original Command New Game
seph_shiftpuzzles_scnttl_cng
# Creates Shift Puzzle Game Data
$game_shiftpuzzle = Game_ShiftPuzzle.new
end
end

#==============================================================================
# ** Scene_Save
#==============================================================================

class Scene_Save
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_shiftpuzzles_scnsave_wd write_data
#--------------------------------------------------------------------------
# * Command : New Game
#--------------------------------------------------------------------------
def write_data(file)
# Original Write Data
seph_shiftpuzzles_scnsave_wd(file)
# Saves Shift Puzzle Data
Marshal.dump($game_shiftpuzzle, file)
end
end

#==============================================================================
# ** Scene_Load
#==============================================================================

class Scene_Load
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_shiftpuzzles_scnload_rd read_data
#--------------------------------------------------------------------------
# * Command : New Game
#--------------------------------------------------------------------------
def read_data(file)
# Original Write Data
seph_shiftpuzzles_scnload_rd(file)
# Saves Shift Puzzle Data
$game_shiftpuzzle = Marshal.load(file)
end
end

#------------------------------------------------------------------------------
# * End SDK Enable Test
#------------------------------------------------------------------------------
end

Who's 백호

?

이상혁입니다.

http://elab.kr

Atachment
첨부 '2'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6203
1021 아이템 흠..몬스터도감말고 아이템도감~ 9 백호 2009.02.21 2028
1020 전투 흠.. 아직도 이 스크립트가 없군요 ㅋㅋ(제가올림..) 1 file 백호 2009.02.21 3337
1019 전투 횡스크롤형식의 스크립트 7 백호 2009.02.21 2982
1018 기타 횡스크롤 스크립트 한국말 번역. 15 file 백호 2009.02.21 3315
1017 기타 회복으로 데미지를 받는 좀비 스크립트 7 백호 2009.02.22 2010
1016 메뉴 화살표 모양 셀렉트 커서 사용 2 백호 2009.02.22 2118
1015 그래픽 화면을 부드럽게 해주는스크립트[ 아주 유용] 56 file - 하늘 - 2009.08.05 6566
1014 미니맵 화면에 축소된 미니맵을 표시하는 스크립트 - 한글 번역 - 6 file 백호 2009.02.21 2560
1013 화면에 축소된 맵을 표시하는 스크립트 7 file 백호 2009.02.21 2394
1012 기타 홈페이지 띄우기 (VX 상관없음.) 6 KNAVE 2009.08.25 2139
1011 메뉴 혹시있나해서-_-.. 대화창에 테두리치기 스크립트 7 백호 2009.02.22 2596
1010 기타 현재시간표시 33 file 코아 코스튬 2010.10.09 2529
1009 기타 현재 맵BGM을 그대로 전투 BGM으로 연결 from phylomortis.com 백호 2009.02.22 1180
1008 이름입력 한글조합입력기(영어가능) file 조규진1 2019.11.10 507
1007 메시지 한글자씩 뜨는 스크립트 6 백호 2009.02.21 3004
1006 키입력 한글입력스크립트 16 file 아방스 2007.11.09 11828
1005 키입력 한글입력기(자음, 모음 분리. 아마 중복일 듯...) 11 캉쿤 2011.09.13 3225
1004 키입력 한글입력기 6 백호 2009.02.22 4306
1003 이름입력 한글이름 입력기 스크립트 14 백호 2009.02.22 4211
1002 메시지 한글 채팅 스크립트 32 file こなた 2009.01.22 4947
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 52 Next
/ 52