Opis:
Skrypt dodaje minigierkę polegającą na wprowadzeniu danej sekwencji klawiszy w ustalonym czasie. Po poprawnym wprowadzeniu zmienna zmienia wartość.
Info: Autor: Shanghai
Tłumaczenie: Angius
Skrypt:
Spoiler:
Kod:
#===============================================================================
#
# Shanghai Simple Script - Minigame Input Match
# Last Date Updated: 2010.05.24
# Level: Normal
#
# This is a minigame script. The game gives you a sequence to input and the
# player follows the sequence. Easy as that.
#===============================================================================
# Instrukcje
# -----------------------------------------------------------------------------
# Aby zainstalować skrypt otwórz edytor skryptów, a następnie wklej kod
# pod sekcją Materials, lecz ponad sekcją Main.
#
# Skrypt wywołaj:
# i = "236C"
# $game_variables[1] = input_match(i,x)
#
# i jest sekwencją, która ma zostać wprowadzona. x to ilość czasu na wprowadzenie
# gdana graczowi. Dla sekwensji użyj poniższychoznaczeń:
#
# 7 8 9 L R UL U UR Q W
# 4 6 X Y Z W skrypcie to L R A S D na klawiaturze
# 1 2 3 A B C DL D DR Sh X Z
#
# Nie pomyl ich. Wynik zapisywany w zmiennej to wynik procentowy tego, jak
# dobrze gracz dopasował sekwencję.
#===============================================================================
$imported = {} if $imported == nil
$imported["MinigameInputMatch"] = true
module SSS
# Poniżej znajduje się nazwa pliku z grafikami do skryptu.
# Umieść go w Graphics\System.
INPUT_MATCH_SHEET = "MiniGameInputMatch"
# Poniżej ustawiasz efekty dźwiękowe.
INPUT_START = RPG::SE.new("Up", 80, 150) # Start wprowadzania
INPUT_TICK = RPG::SE.new("Cursor", 80, 150) # Kliknięcie przycisku
INPUT_CORRECT = RPG::SE.new("Decision2", 80, 150) # Poprawny przycisk wciśniety
INPUT_WRONG = RPG::SE.new("Buzzer1", 80, 150) # Niepoprawny
INPUT_PERFECT = RPG::SE.new("Chime2", 80, 120) # Doskonały wynik
INPUT_ALMOST = RPG::SE.new("Decision2", 80, 100) # Prawie dobrze
INPUT_MISSED = RPG::SE.new("Buzzer2", 80, 100) # Żle
module SPRITESET
#--------------------------------------------------------------------------
# * Input Match Game
#--------------------------------------------------------------------------
def input_match(string = "236C", time = 0)
@time = time
@time = string.size * 30 if time < 1
@input_string = []
@ebuffer = 10
string.size.times do
c = string.slice!(/./m)
case c
when "1"; @input_string.push(:i1)
when "2"; @input_string.push(:i2)
when "3"; @input_string.push(:i3)
when "4"; @input_string.push(:i4)
when "6"; @input_string.push(:i6)
when "7"; @input_string.push(:i7)
when "8"; @input_string.push(:i8)
when "9"; @input_string.push(:i9)
when "A"; @input_string.push(:kA)
when "B"; @input_string.push(:kB)
when "C"; @input_string.push(:kC)
when "X"; @input_string.push(:kX)
when "Y"; @input_string.push(:kY)
when "Z"; @input_string.push(:kZ)
when "L"; @input_string.push(:kL)
when "R"; @input_string.push(:kR)
else; next
end
end
@correct_input = 0
@current_input = 0
create_input_match_sprites
end
#--------------------------------------------------------------------------
# * Create Input Match Sprites
#--------------------------------------------------------------------------
def create_input_match_sprites
# Make Input Dummy Window
w = @input_string.size * 48 + 32
y = (Graphics.height - 80) / 2
x = (Graphics.width - w) / 2
@input_match_dummy_window = Window_Base.new(x, y, w, 80)
@input_match_dummy_window.viewport = @viewport3
# Make Input Timer
@buffer = 40
@input_timer = Sprite_InputTimer.new(@viewport3, @input_match_dummy_window)
# Make Input Sprites
@image = Cache.system(SSS::INPUT_MATCH_SHEET)
bitmap = Bitmap.new(@input_string.size * 48, 24)
bitmap_x = 12
for input_id in @input_string
case input_id
when :i1; rect = Rect.new( 0, 48, 24, 24)
when :i2; rect = Rect.new( 24, 48, 24, 24)
when :i3; rect = Rect.new( 48, 48, 24, 24)
when :i4; rect = Rect.new( 0, 24, 24, 24)
when :i6; rect = Rect.new( 48, 24, 24, 24)
when :i7; rect = Rect.new( 0, 0, 24, 24)
when :i8; rect = Rect.new( 24, 0, 24, 24)
when :i9; rect = Rect.new( 48, 0, 24, 24)
when :kA; rect = Rect.new( 72, 48, 24, 24)
when :kB; rect = Rect.new( 96, 48, 24, 24)
when :kC; rect = Rect.new(120, 48, 24, 24)
when :kX; rect = Rect.new( 72, 24, 24, 24)
when :kY; rect = Rect.new( 96, 24, 24, 24)
when :kZ; rect = Rect.new(120, 24, 24, 24)
when :kL; rect = Rect.new( 72, 0, 24, 24)
when :kR; rect = Rect.new( 96, 0, 24, 24)
else; next
end
bitmap.blt(bitmap_x, 0, @image, rect)
bitmap_x += 48
end
@input_match_sprite = Sprite_Base.new(@viewport3)
@input_match_sprite.bitmap = bitmap
@input_match_sprite.z = @input_match_dummy_window.z + 1
@input_match_sprite.x = @input_match_dummy_window.x + 16
@input_match_sprite.y = @input_match_dummy_window.y + 40
end
#--------------------------------------------------------------------------
# * Dispose Input Match Sprites
#--------------------------------------------------------------------------
def dispose_input_match_sprites
unless @input_match_dummy_window.nil?
@input_match_dummy_window.dispose
@input_match_dummy_window = nil
end
unless @input_timer.nil?
@input_timer.dispose
@input_timer = nil
end
unless @input_match_sprite.nil?
@input_match_sprite.bitmap.dispose
@input_match_sprite.dispose
@input_match_sprite = nil
end
unless @input_result_sprite.nil?
@input_result_sprite.bitmap.dispose
@input_result_sprite.dispose
@input_result_sprite = nil
end
end
#--------------------------------------------------------------------------
# * Update Input Match
#--------------------------------------------------------------------------
def update_input_match
if @buffer > 0
@buffer -= 1
@input_timer.update
@input_match_sprite.update
SSS::INPUT_START.play if @buffer == 0
return
end
@time -= 1 unless @time < 1
SSS::INPUT_TICK.play if @time % 60 == 0
update_input_match_button
@input_match_sprite.update
@input_timer.update
end
#--------------------------------------------------------------------------
# * Update Input Match Button
#--------------------------------------------------------------------------
def update_input_match_button
if Input.trigger?(Input::A)
key = :kA
elsif Input.trigger?(Input::B)
key = :kB
elsif Input.trigger?(Input::C)
key = :kC
elsif Input.trigger?(Input::X)
key = :kX
elsif Input.trigger?(Input::Y)
key = :kY
elsif Input.trigger?(Input::Z)
key = :kZ
elsif Input.trigger?(Input::L)
key = :kL
elsif Input.trigger?(Input::R)
key = :kR
elsif Input.dir8 != 0
case Input.dir8
when 1; key = :i1
when 2; key = :i2
when 3; key = :i3
when 4; key = :i4
when 6; key = :i6
when 7; key = :i7
when 8; key = :i8
when 9; key = :i9
else; return
end
else
return
end
check_input_key(key)
end
#--------------------------------------------------------------------------
# * Check Input Key
#--------------------------------------------------------------------------
def check_input_key(key)
good = key == @input_string[@current_input]
if good
@correct_input += 1
SSS::INPUT_CORRECT.play
rect = Rect.new(24, 24, 24, 24)
else
if [:i1, :i2, :i3, :i4, :i6, :i7, :i8, :i9].include?(key) and @ebuffer > 0
@ebuffer -= 1
return if @ebuffer > 0
end
SSS::INPUT_WRONG.play
rect = Rect.new(120, 0, 24, 24)
end
@ebuffer = 10
@input_match_sprite.bitmap.blt(@current_input * 48 + 12, 0, @image, rect)
@current_input += 1
end
#--------------------------------------------------------------------------
# * Break Input Match
#--------------------------------------------------------------------------
def break_input_match
return true if @current_input == @input_string.size
return true if @time < 1
return false
end
#--------------------------------------------------------------------------
# * Input Match Results
#--------------------------------------------------------------------------
def input_match_results
@buffer = 60
loop do
$scene.update_basic
@buffer -= 1
break if @buffer < 1
end
score = (@correct_input * 100 / @input_string.size)
case score
when 100
rect = Rect.new(144, 0, 96, 24)
SSS::INPUT_PERFECT.play
when 60..99
rect = Rect.new(144, 24, 96, 24)
SSS::INPUT_ALMOST.play
else
rect = Rect.new(144, 48, 96, 24)
SSS::INPUT_MISSED.play
end
# Make Input Results Sprite
@input_result_sprite = Sprite_Base.new(@viewport3)
@input_result_sprite.bitmap = Bitmap.new(96, 24)
@input_result_sprite.bitmap.blt(0, 0, @image, rect)
@input_result_sprite.zoom_x = @input_result_sprite.zoom_y = 2.0
@input_result_sprite.ox = 48
@input_result_sprite.oy = 24
@input_result_sprite.z = 300
@input_result_sprite.x = Graphics.width / 2
@input_result_sprite.y = Graphics.height / 2
@input_result_sprite.opacity = 0
raise = 20
raise.times do
@input_result_sprite.opacity += 16
@input_result_sprite.y -= 2
@input_result_sprite.update
$scene.update_basic
end
loop do
@input_result_sprite.opacity -= 4
@input_result_sprite.update
$scene.update_basic
break if @input_result_sprite.opacity < 1
end
# Dispose
dispose_input_match_sprites
return score
end
end
end
class Game_Interpreter
#--------------------------------------------------------------------------
# * Input Match
#--------------------------------------------------------------------------
def input_match(string = "236C", time = 0)
return false unless $scene.is_a?(Scene_Map) or $scene.is_a?(Scene_Battle)
return $scene.input_match(string, time)
end
end
class Spriteset_Map
include SSS::SPRITESET
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :time
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
alias dispose_sss_spriteset_map_input_match dispose unless $@
def dispose
dispose_sss_spriteset_map_input_match
dispose_input_match_sprites
end
end
class Spriteset_Battle
include SSS::SPRITESET
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :time
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
alias dispose_sss_spriteset_battle_input_match dispose unless $@
def dispose
dispose_sss_spriteset_battle_input_match
dispose_input_match_sprites
end
end
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :spriteset
#--------------------------------------------------------------------------
# * Input Match Game
#--------------------------------------------------------------------------
def input_match(string = "236C", time = 0)
@spriteset.input_match(string, time)
loop do
update_basic
@spriteset.update_input_match
break if @spriteset.break_input_match
end
return @spriteset.input_match_results
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :spriteset
#--------------------------------------------------------------------------
# * Input Match Game
#--------------------------------------------------------------------------
def input_match(string = "236C", time = 0)
@spriteset.input_match(string, time)
loop do
update_basic
@spriteset.update_input_match
break if @spriteset.break_input_match
end
return @spriteset.input_match_results
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:
# i = "236C"
# $game_variables[1] = input_match(i,x)
#
# i jest sekwencją, która ma zostać wprowadzona. x to ilość czasu na wprowadzenie
# gdana graczowi. Dla sekwensji użyj poniższychoznaczeń:
#
# 7 8 9 L R UL U UR Q W
# 4 6 X Y Z W skrypcie to L R A S D na klawiaturze
# 1 2 3 A B C DL D DR Sh X Z
#
# Nie pomyl ich. Wynik zapisywany w zmiennej to wynik procentowy tego, jak
# dobrze gracz dopasował sekwencję.
Numer przy game_variables to oczywiście numer zmiennej. Wystarczy jedna zmienna na cały skrypt.
Może by tak dać demko? Ja próbowałem ponad godzinę i nic mi nie wychodziło.
________________________ Szukam grafika do mojego projektu o nazwie ,,The Magic Warrior".
Grafik miałby za zadanie tworzenie lokacji do gry, chartsetów, baletersów oraz wiele innych rzeczy związanych z grafiką. Zainteresowanych proszę pisać na pocztę asdasd7251@tlen.pl. W temacie proszę pisać ,,Grafik w projekcie The Magic Warrior"
Wiem, że temat dość długo nie ruszany, ale ostatnio siadłem do tego skryptu i też niewiele czaiłem. Postanowiłem, więc poszukać demo i podzielić się nim z wami.
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