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 6153
721 메뉴 링메뉴 스크립트 file 백호 2009.02.21 1391
720 기타 게이지 3 백호 2009.02.21 1394
719 텔로포트 스크립트 8 WMN 2008.03.17 1397
718 저장 Woratana's Neo Save System for RMXP by LiTTleDRAgo 5 Alkaid 2013.01.19 1398
717 메뉴 콤보 스크립트 백호 2009.02.22 1399
716 영상 berka's Video Script II Reloaded 1.2 2 Alkaid 2010.10.08 1399
715 기타 마법반사스크립트 4 *ps인간 2009.01.26 1403
714 저장 오류 수정한 자동세이브 2 백호 2009.02.22 1403
713 기타 Multiple Languages v2 by SephirothSpawn (SDK호환) file 백호 2009.02.22 1404
712 전투 KGC_PreempAttack(선제공격) file 백호 2009.02.22 1405
711 기타 필요 경험치 직접 정하기 9 백호 2009.02.21 1407
710 기타 풀스크린 스크립트 2 백호 2009.02.22 1407
709 이동 및 탈것 KGC_SetAttackElement (공격속성설정) file 백호 2009.02.22 1407
708 전투 숙력도 시스템 스크립트 2 백호 2009.02.21 1408
707 타이틀/게임오버 타이틀음악 백호 2009.02.22 1410
706 메뉴 링메뉴에 돈(G)표시하기 백호 2009.02.21 1413
705 기타 비밀소년님의 경험치 표시 스크립트 백호 2009.02.22 1419
704 저장 [신기술 체험] 데이터 저장 6 file 백호 2009.02.22 1420
703 키입력 전체 키 사용 스크립트 1 백호 2009.02.21 1423
702 전투 마법검 스크립트 1 백호 2009.02.22 1425
Board Pagination Prev 1 ... 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ... 52 Next
/ 52