Opis:
Skrypt dodaje minigierkę polegającą po prostu na nawalaniu w przycisk i uzyskaniu danej liczby naciśnięć w danym czasie.
Info: Autor: Shanghai
Tłumaczenie: Angius
Skrypt:
Spoiler:
Kod:
#===============================================================================
#
# Shanghai Simple Script - Minigame Button Mash
# Last Date Updated: 2010.05.18
# Level: Normal
#
# This is the all purpose button mashing minigame. This minigame sets a timer
# and the animation to be played for the button mashing event. It will return
# the amount of times the button has been mashed.
#===============================================================================
# Instrukcje
# -----------------------------------------------------------------------------
# Aby zainstalować skrypt otwórz edytor skryptów, a następnie wklej kod
# pod sekcją Materials, lecz ponad sekcją Main.
#
# Skrypt wywołaj:
# $game_variables[1] = button_mash(t,a,b)
#
# t oznacza czas w sekundach. a jest ID animacji, która ma się pojawiać po
# naciśnięciu przycisku. b to guzik, który ma być naciskany.
#
# L R Q W
# X Y Z w skrypcie odpowiada A S D na klawiaturze
# A B C Sh Z X
#
#===============================================================================
$imported = {} if $imported == nil
$imported["MinigameButtonMash"] = true
module SSS
# Poniżej znajduje się nazwa pliku z grafikami do skryptu.
# Umieść go w Graphics\System.
BUTTON_MASH_SHEET = "MiniGameButtonMash"
BUTTON_MASH_TEXT = "%s×"
# Poniżej ustawiasz efekty dźwiękowe.
MASH_START = RPG::SE.new("Up", 80, 150) #Start odliczania czasu
MASH_TICK = RPG::SE.new("Cursor", 80, 150) #Kliknięcie
module SPRITESET
#--------------------------------------------------------------------------
# * Button Mash Game
#--------------------------------------------------------------------------
def button_mash_game(time = 5, animation = 1, button = "Z")
@time = [time, 1].max * 60
@button_mash_animation = $data_animations[animation]
case button.upcase
when "A", "B", "C", "X", "Y", "Z", "L", "R"
@mash_button = eval("Input::" + button.upcase)
else
@mash_button = Input::Z
end
@disposable_sprites = []
@start_buffer = 60
@times_mashed = 0
create_button_mash_sprites(button)
end
#--------------------------------------------------------------------------
# * Create Button Mash Sprites
#--------------------------------------------------------------------------
def create_button_mash_sprites(button)
# Create Giant Button Sprite
@button_sprite = Sprite_Base.new(@viewport2)
@button_sprite.bitmap = Bitmap.new(48, 48)
bitmap = Cache.system(SSS::BUTTON_MASH_SHEET)
case button.upcase
when "L"; rect = Rect.new( 0, 24, 24, 24)
when "R"; rect = Rect.new(24, 24, 24, 24)
when "X"; rect = Rect.new( 0, 48, 24, 24)
when "Y"; rect = Rect.new(24, 48, 24, 24)
when "Z"; rect = Rect.new(48, 48, 24, 24)
when "A"; rect = Rect.new( 0, 72, 24, 24)
when "B"; rect = Rect.new(24, 72, 24, 24)
else; rect = Rect.new(48, 72, 24, 24)
end
@button_sprite.bitmap.stretch_blt(Rect.new(0, 0, 48, 48), bitmap, rect)
@button_sprite.ox = @button_sprite.oy = 24
@button_sprite.x = Graphics.width/2
@button_sprite.y = Graphics.height/2
@button_sprite.z = 100
# Create Giant Hand Sprite
@finger_sprite = Sprite_Base.new(@viewport3)
@finger_sprite.bitmap = Bitmap.new(48, 48)
rect = Rect.new(48, 24, 24, 24)
@finger_sprite.bitmap.stretch_blt(Rect.new(0, 0, 48, 48), bitmap, rect)
@finger_sprite.oy = 48
@finger_sprite.x = Graphics.width/2
@finger_sprite.y = Graphics.height/3
@finger_sprite.z = 500
# Create Instructions Sprite
@instruction_sprite = Sprite_Base.new(@viewport3)
@instruction_sprite.bitmap = Bitmap.new(72, 24)
@instruction_sprite.bitmap.blt(0, 0, bitmap, Rect.new(0, 0, 72, 24))
@instruction_sprite.ox = 36
@instruction_sprite.x = Graphics.width/2
@instruction_sprite.y = Graphics.height-152
@instruction_sprite.z = 99
# Create Timer
@mash_timer_sprite = Sprite_MashTimer.new(@viewport3)
# Create Times Mashed Sprite
@mash_number_sprite = Sprite_Base.new(@viewport3)
@mash_number_sprite.bitmap = Bitmap.new(Graphics.width/4, 48)
@mash_number_sprite.bitmap.font.size = 32
t = sprintf(SSS::BUTTON_MASH_TEXT, "0")
@mash_number_sprite.bitmap.draw_text(0, 0, Graphics.width/4, 48, t, 1)
@mash_number_sprite.ox = Graphics.width/8
@mash_number_sprite.oy = 24
@mash_number_sprite.x = Graphics.width/4
@mash_number_sprite.y = Graphics.height/4-12
end
#--------------------------------------------------------------------------
# * Dispose Button Mash Sprites
#--------------------------------------------------------------------------
def dispose_button_mash_sprites
unless @button_sprite.nil?
@button_sprite.bitmap.dispose
@button_sprite.dispose
@button_sprite = nil
end
unless @finger_sprite.nil?
@finger_sprite.bitmap.dispose
@finger_sprite.dispose
@finger_sprite = nil
end
unless @instruction_sprite.nil?
@instruction_sprite.bitmap.dispose
@instruction_sprite.dispose
@instruction_sprite = nil
end
unless @mash_timer_sprite.nil?
@mash_timer_sprite.dispose
@mash_timer_sprite = nil
end
unless @mash_number_sprite.nil?
@mash_number_sprite.bitmap.dispose
@mash_number_sprite.dispose
@mash_number_sprite = nil
end
@disposable_sprites = [] if @disposable_sprites.nil?
for sprite in @disposable_sprites
sprite.bitmap.dispose
sprite.dispose
end
@disposable_sprites = []
end
#--------------------------------------------------------------------------
# * Update Button Mash
#--------------------------------------------------------------------------
def update_button_mash
if @start_buffer > 0
@start_buffer -= 1
SSS::MASH_START.play if @start_buffer < 1
return
end
@time -= 1 if @time > 0
if Input.trigger?(@mash_button) and @time > 0
@finger_sprite.y = Graphics.height/2
button_mash_animation
else
@finger_sprite.y = [@finger_sprite.y - 8, Graphics.height/3].max
end
@button_sprite.update
@finger_sprite.update
@instruction_sprite.update
@mash_timer_sprite.update
@mash_number_sprite.update
for sprite in @disposable_sprites
sprite.update
end
end
#--------------------------------------------------------------------------
# * Button Mash Animation
#--------------------------------------------------------------------------
def button_mash_animation
sprite = Sprite_Base.new(@viewport2)
sprite.bitmap = Bitmap.new(48, 48)
sprite.ox = sprite.oy = 24
sprite.x = Graphics.width/2
sprite.y = Graphics.height/2
Sound.play_cursor if @button_mash_animation.nil?
sprite.start_animation(@button_mash_animation)
@disposable_sprites.push(sprite)
@times_mashed += 1
# Redraw Mash Number
@mash_number_sprite.bitmap.dispose
@mash_number_sprite.bitmap = Bitmap.new(Graphics.width/4, 48)
@mash_number_sprite.bitmap.font.size = 32
t = sprintf(SSS::BUTTON_MASH_TEXT, @times_mashed.to_s)
@mash_number_sprite.bitmap.draw_text(0, 0, Graphics.width/4, 48, t, 1)
@mash_number_sprite.ox = Graphics.width/8
@mash_number_sprite.oy = 24
@mash_number_sprite.x = Graphics.width/4
@mash_number_sprite.y = Graphics.height/4-12
end
#--------------------------------------------------------------------------
# * Break Button Mash
#--------------------------------------------------------------------------
def break_button_mash
return false unless @finger_sprite.y == Graphics.height/3
return false if @time > 0
for sprite in @disposable_sprites
return false if sprite.animation?
end
return true
end
#--------------------------------------------------------------------------
# * Finish Button Mash
#--------------------------------------------------------------------------
def finish_button_mash
loop do
$scene.update_basic
@button_sprite.opacity -= 4
@finger_sprite.opacity -= 4
@instruction_sprite.opacity -= 4
@mash_timer_sprite.opacity -= 4
@mash_number_sprite.opacity -= 4
@button_sprite.update
@finger_sprite.update
@instruction_sprite.update
@mash_timer_sprite.update
@mash_number_sprite.update
break if @button_sprite.opacity < 1
end
dispose_button_mash_sprites
return @times_mashed
end
end
end
class Spriteset_Map
include SSS::SPRITESET
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :time
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
alias dispose_sss_spriteset_map_button_mash dispose unless $@
def dispose
dispose_sss_spriteset_map_button_mash
dispose_button_mash_sprites
end
end
class Spriteset_Battle
include SSS::SPRITESET
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :time
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
alias dispose_sss_spriteset_battle_button_mash dispose unless $@
def dispose
dispose_sss_spriteset_battle_button_mash
dispose_button_mash_sprites
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :spriteset
#--------------------------------------------------------------------------
# * Button Mash Game
#--------------------------------------------------------------------------
def button_mash(time = 5, animation = 1, button = "Z")
@spriteset.button_mash_game(time, animation, button)
loop do
update_basic
@spriteset.update_button_mash
break if @spriteset.break_button_mash
end
return @spriteset.finish_button_mash
end
end
#===============================================================================
#
# END OF FILE
#
#===============================================================================
Konfiguracja:
Kod:
# Aby zainstalować skrypt otwórz edytor skryptów, a następnie wklej kod
# pod sekcją Materials, lecz ponad sekcją Main.
#
# Skrypt wywołaj:
# $game_variables[1] = button_mash(t,a,b)
#
# t oznacza czas w sekundach. a jest ID animacji, która ma się pojawiać po
# naciśnięciu przycisku. b to guzik, który ma być naciskany.
#
# L R Q W
# X Y Z w skrypcie odpowiada A S D na klawiaturze
# A B C Sh Z X
Numer przy game_variables to oczywiście numer zmiennej. Wystarczy jedna zmienna na cały skrypt.
Grafiki:
________________________
"Na trolla pewne są tylko dwie pewne metody, jedna samopowtarzalna i druga, wymagająca przeładowania ręcznego."
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach Nie możesz załączać plików na tym forum Możesz ściągać załączniki na tym forum