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 6156
301 메뉴 링메뉴 스크립트 file 백호 2009.02.21 1391
300 기타 간단한 Scene_Base Alkaid 2010.09.09 1391
» 기타 Shift Puzzles by SephirothSpawn (SDK호환) 1 file 백호 2009.02.22 1389
298 스킬 Skills_Consume_Hp[By: Gando] - HP를 소비하는 스킬 스크립트 4 쉴더 2009.02.21 1385
297 기타 KGC_UsableWeapon file 백호 2009.02.22 1384
296 기타 CG모드 도입 스크립트 file 백호 2009.02.21 1383
295 이동 및 탈것 금금님 요청 대쉬 1 백호 2009.02.22 1383
294 이동 및 탈것 플레이어 텔레포트 시키기 1 백호 2009.02.22 1375
293 메뉴 Ring menu edit for SDK2 (Original by Hypershadow180) file Alkaid 2010.09.08 1374
292 기타 [All RGSS] 게임 다중 실행 방지 스크립트 1 file Cheapmunk 2014.05.24 1374
291 오디오 Audio Module Rewrite mciSendString 1.1 by DerVVulfman Alkaid 2012.09.18 1367
290 기타 Chaos Project Debug System 1.06b by Blizzard file Alkaid 2010.09.07 1367
289 변수/스위치 지정범위안에 들어오면 특정 스위치를 온/오프/교환 한다!! 2 백호 2009.02.21 1365
288 기타 스크린샷 찍는 스크립트 9 file 백호 2009.02.22 1363
287 기타 Minesweeper(지뢰찾기) by SephirothSpawn (SDK호환) 3 file 백호 2009.02.22 1363
286 기타 빛의 퍼즐 -미니게임- 1 file 백호 2009.02.21 1360
285 장비 KGC_EquipmentBreak(장비품 파괴) 1 백호 2009.02.22 1356
284 전투 매턴 자동 회복이나 도트힐 3 file 백호 2009.02.22 1351
283 기타 실제시간표시스크립트입니다...[중뷁이면지성;;] 4 백호 2009.02.22 1349
282 기타 (T-RPG) 데미지 표시 시의 폰트를 설정 백호 2009.02.22 1348
Board Pagination Prev 1 ... 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 ... 52 Next
/ 52