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 6202
» 기타 Shift Puzzles by SephirothSpawn (SDK호환) 1 file 백호 2009.02.22 1390
173 기타 Shift Puzzles v2 by SephirothSpawn (SDK호환) 3 file 백호 2009.02.22 1170
172 기타 Sized Events 0.1 by Toby@rmxp.org file 백호 2009.02.22 848
171 기타 Sphere Grid System file 백호 2009.02.21 765
170 기타 Steal Script (SDK Required) file 백호 2009.02.21 1182
169 기타 Tax Script 1.2 by The Darklord@rmxp.org 2 file 백호 2009.02.22 1130
168 기타 Terrain Encounter Areas by SephirothSpawn 백호 2009.02.22 778
167 기타 Tetris Attack by trickster 1 file 백호 2009.02.22 986
166 기타 Text Scroll by Dubealex (Release 3) 2 file 백호 2009.02.22 940
165 기타 Text to RGSS by DerVVulfman Alkaid 2011.04.18 1319
164 기타 The General Monster Generator 1.1 by DerVVulfman 1 file Alkaid 2011.03.02 1496
163 기타 Trailing Characters ver.1 by SephirothSpawn 6 file 백호 2009.02.22 1551
162 기타 Upload & Download files with RGSS 2.1 by berka (XP/VX 공용) 5 Alkaid 2010.11.20 2138
161 기타 Weather Script 1.02 by ccoa 1 file 백호 2009.02.22 810
160 기타 XP 각종 스크립트입니다. 36 file 쿠도신이치 2009.04.26 4272
159 기타 [All RGSS] File-Ex file Cheapmunk 2014.12.29 964
158 기타 [All RGSS] FileTest (Unicode) file Cheapmunk 2014.12.29 614
157 기타 [All RGSS] 게임 다중 실행 방지 스크립트 1 file Cheapmunk 2014.05.24 1381
156 기타 [All RGSS] 윈도우 메세지박스 스크립트 (Completed ver) 5 file Cheapmunk 2014.06.22 2186
155 기타 [All RGSS] 윈도우 커서 숨기기/보이기 1 file Cheapmunk 2014.03.02 1962
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 Next
/ 13