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
601 파티 메뉴커맨드로 파티 멤버들 순서 바꾸기 by Yargovish 1 백호 2009.02.22 1622
600 오디오 WinAMP 플러그인을 이용하여 RMXP에서 다른 형식의 음악파일 재생하기 file 백호 2009.02.22 1259
599 기타 아래 스크립트에 대한 Guillaume777님의 개량판입니다. 백호 2009.02.22 880
598 아이템 아이템을 얻으면 자동으로 아이템 입수 메세지윈도우 띄우기 4 백호 2009.02.22 2279
597 메뉴 자작 커스텀 메뉴(데모 첨부) 3 백호 2009.02.22 2348
596 메뉴 KGC 메뉴화면 개조 스크립트 번역 3 file 백호 2009.02.22 1942
595 기타 KGC 디버거 (최신 올라온 것에 비해 성능은 딸리지만) file 백호 2009.02.22 929
594 장비 Multi-equip script ver.6 by Guillaume777 4 file 백호 2009.02.22 1210
593 기타 일시정지 스크립트 2 file 백호 2009.02.22 1796
592 아이템 아이템 인벤토리 2 file 백호 2009.02.22 3356
591 기타 Weather Script 1.02 by ccoa 1 file 백호 2009.02.22 810
590 메시지 Animated Window Skin by Tana 1 백호 2009.02.22 1338
589 스킬 Skill Shop by SephirothSpawn file 백호 2009.02.22 813
588 기타 다중 파노라마 사용 by Guillaume777 file 백호 2009.02.22 886
587 그래픽 Bitmap update 2.0 by Linkin_T 1 백호 2009.02.22 985
586 기타 ABS 몬스터 HP 게이지 바 11 백호 2009.02.22 2485
585 맵/타일 Map Event Large Make 2 백호 2009.02.22 1134
584 기타 파노라마 스크롤 스크립트 개량판 by Guillaume777 1 백호 2009.02.22 896
583 HUD 맵 이름 표시 by Slipknot@rmxp.net (SDK호환) 2 백호 2009.02.22 1463
582 기타 제작한 게임의 파일을 모두 exe파일 하나에 쓸어담기 by sheefo@Creation Asylum 1 file 백호 2009.02.22 1240
Board Pagination Prev 1 ... 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ... 52 Next
/ 52