Jump to content
Rpg²S Forum

Minigioco del Puzle


Belxebu
 Share

Recommended Posts

Scene_Puzle

Descrizione

Il minigioco del puzzle,un vecchio script per l'XP che ho modificato e grazie alla Total Conversion funge anche su VX(RICHIEDE LA TOTAL CONVERSION)

 

Autore

DarkRog riadattato da me

 

Istruzioni per l'uso

Inserire 2 immagini(preferibilmente le stesse)di grandezza 420x420 da chiamare una Baxk e l'altra Puzle1 in Graphics/Pictures e inserire lo script
SOTTO
la Total Conversion,per richiamare lo script ci sono le istruzioni dentro lo script(un esempio di come avviare lo script:
$scene = Scene_Puzle.new(140, "Puzle1", 3, 30, "Back")

 

 

 

 

#==============================================================================
# ■ Scene_Puzle - By DarkRog - Versión Pase automático de piezas.
#  MODIFICATO E ADATTATO PER VX DA RINNEGATAMANTE
#You need a picture with size 420px x 420px, in Graphics/Pictures.
#You have to call a script from an event and write:
#$scene = Scene_Puzle.new(piece size , "picture", variable id (this variable will be the result of the game), time, background)
#*The size has to be dividing of 420.
#*The picture need to be in Graphics/Picture.
#*The variable id:
#1:You won, 2:Time up.
#*Seconds, or false for unlimited time.
#*A background image in Graphics/Picture, or false for any picture.
#Example:
#$scene = Scene_Puzle.new(140, "Puzle1", 3, 30, "Back")
#Size:140, Picture:"Puzle1", Variable:3, Seconds:30 Background:"Back".
#------------------------------------------------------------------------------

class Scene_Puzle
def initialize(size, img, vid, tim, back)
@pu = Window_Puzle.new(size, img, vid, tim, back)
end
def main
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@pu.dispose
if $scene.is_a?(Scene_Title)
Graphics.transition
Graphics.freeze
end
end
def update
@pu.refresh
end
end

class Window_Puzle < Window_Base
def initialize(size, img, vid, tim, back)
super(-16, -16, 640+32, 480+32)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = 20
@back = back
@vid = vid
@piezasi = size
@img = img
@winb = Window_PBrillo.new
if tim == false
@timeh = false
else
@time = tim*25
@timeh = true
end
@pieza = []
piezas = []
num = 0
for i in 0..420/@piezasi-1
for a in 0..420/@piezasi-1
@pieza[num] = Pieza_Puzle.new(a, i)
piezas[num] = num
num += 1
end
end
@op = []
for i in 0..420/@piezasi*420/@piezasi-1
loop do
ra = rand(420/@piezasi*420/@piezasi)
if piezas[ra] != nil
@op[i] = ra
piezas[ra] = nil
break
end
end
end
@cursor = num-1
@o = 100
@re = false
refresh
end
def refresh
self.contents.clear
$fontface = "Monotype Corsiva"
$fontsize = 24
if @back != false
self.contents.blt(0, 0, Cache.picture(@back), Rect.new(0, 0, 640, 480), 255)
end
if @timeh == true
@time -= 1
if @time == 0
$game_variables[@vid] = 2
$game_system.se_play($data_system.buzzer_se)
$scene = Scene_Map.new
end
end
if @o <= 100
@re = false
elsif @o >= 255
@re = true
end
if @re == false
@o += 5
elsif @re == true
@o -= 5
end
self.contents.draw_text(26, 0, 640, 32, "Pezzi")
self.contents.font.name = "Monotype Corsiva"
self.contents.font.size = 24
self.contents.draw_text(300, 0, 640, 32, "Pannello")
self.contents.font.name = "Monotype Corsiva"
self.contents.font.size = 24
if @timeh != false
if @time/25%60 > 9
self.contents.draw_text(460, 0, 640, 32, "Tempo: #{@time/25/60}:#{@time/25%60}")
self.contents.font.name = "Monotype Corsiva"
self.contents.font.size = 24
else
self.contents.draw_text(460, 0, 640, 32, "Tempo: #{@time/25/60}:0#{@time/25%60}")
self.contents.font.name = "Monotype Corsiva"
self.contents.font.size = 24
end
else
self.contents.draw_text(420, 0, 640, 32, "Tempo Illimitato")
self.contents.font.name = "Monotype Corsiva"
self.contents.font.size = 24
end
self.contents.fill_rect(70-@piezasi/2+@piezasi/100, 240-@piezasi/2, @piezasi+2, @piezasi+2, Color.new(0, 0, 0, 200))
self.contents.fill_rect(175, 35, 422, 422, Color.new(0, 0, 0, 200))
self.contents.blt(176, 36, Cache.picture(@img), Rect.new(0, 0, 420, 420), 10)
pieza = 0
for i in 0..420/@piezasi-1
for a in 0..420/@piezasi-1
if @pieza[pieza].d == true
self.contents.blt(176+a*@piezasi, 36+i*@piezasi, Cache.picture(@img), Rect.new(@piezasi*a, @piezasi*i, @piezasi, @piezasi), 255)
end
pieza += 1
end
end
for a in -1..1
i = @cursor-a
if @op[i] != nil
if i >= 0 and a != 0
if @pieza[@op[i]].d == false
elsif @pieza[@op[i]].d == true
end
end
if a == 0
if @pieza[@op[i]].d == false
self.contents.blt(70-@piezasi/2+@piezasi/100+1, 240-@piezasi*3/2+@piezasi*(a+1), Cache.picture(@img), Rect.new(@pieza[@op[i]].x*@piezasi, @pieza[@op[i]].y*@piezasi, @piezasi, @piezasi), @o)
elsif @pieza[@op[i]].d == true
self.contents.blt(70-@piezasi/2+@piezasi/100+1, 240-@piezasi*3/2+@piezasi*(a+1), Cache.picture(@img), Rect.new(@pieza[@op[i]].x*@piezasi, @pieza[@op[i]].y*@piezasi, @piezasi, @piezasi), 20+@o/10)
end
end
end
end
if @fase == 1
f1_up
return
elsif @fase == nil
@fase = 1
@cursorx = 0
@cursory = 0
end
end


def f1_up
self.contents.blt(@piezasi*@cursorx+176, 36+@piezasi*@cursory, Cache.picture(@img), Rect.new(@pieza[@op[@cursor]].x*@piezasi, @pieza[@op[@cursor]].y*@piezasi, @piezasi, @piezasi), @o)
if Input.repeat?(Input::RIGHT) and @cursorx < 420/@piezasi-1
@cursorx += 1
$game_system.se_play($data_system.cursor_se)
elsif Input.repeat?(Input::RIGHT) and @cursorx == 420/@piezasi-1
$game_system.se_play($data_system.cursor_se)
@cursorx = 0
end
if Input.repeat?(Input::LEFT) and @cursorx > 0
@cursorx -= 1
$game_system.se_play($data_system.cursor_se)
elsif Input.repeat?(Input::LEFT) and @cursorx == 0
$game_system.se_play($data_system.cursor_se)
@cursorx = 420/@piezasi-1
end
if Input.repeat?(Input::DOWN) and @cursory < 420/@piezasi-1
@cursory += 1
$game_system.se_play($data_system.cursor_se)
elsif Input.repeat?(Input::DOWN) and @cursory == 420/@piezasi-1
@cursory = 0
$game_system.se_play($data_system.cursor_se)
end
if Input.repeat?(Input::UP) and @cursory >0
@cursory -= 1
$game_system.se_play($data_system.cursor_se)
elsif Input.repeat?(Input::UP) and @cursory == 0
@cursory = 420/@piezasi-1
$game_system.se_play($data_system.cursor_se)
end
if Input.trigger?(Input::C)
if @pieza[@op[@cursor]].x == @cursorx and @pieza[@op[@cursor]].y == @cursory
$game_system.se_play($data_system.load_se)
@pieza[@op[@cursor]].d = true
piezac = 0
for i in 0...420/@piezasi*420/@piezasi
if @pieza[i].d == true
piezac +=1
end
end
if piezac == 420/@piezasi*420/@piezasi
$game_variables[@vid] = 1
@o2 = 0
@re2 = false
@t2 = 0
Audio.se_play("Audio/SE/056-Right02.ogg", 100, 50)
loop do
Graphics.update
@t2 += 1
if @re2 == true
@o2 -= 5
elsif @re2 == false
@o2 += 5
end
if @o2 >= 255
@re2 = true
elsif @o2 <= 0
@re2 = false
end
@winb.refresh(@o2)
if @t2 == 102
@winb.dispose
break
end
end
$game_system.se_play($data_system.shop_se)
$scene = Scene_Map.new
else
@cursor -= 1
end
else
$game_system.se_play($data_system.buzzer_se)
end
return
end
end

end

class Pieza_Puzle
attr_accessor :x
attr_accessor :y
attr_accessor :d
def initialize(x, y)
@x = x
@y = y
@d = false
end
end

class Window_PBrillo < Window_Base
def initialize
super(-16, -16, 640+32, 480+32)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = 20
self.opacity = 0
refresh(0)
end
def refresh(o)
self.contents.clear
$fontsize == 24
$fontface == "Monotype Corsiva"
self.contents.fill_rect(175, 35, 422, 422, Color.new(255, 255, 255, o))
end
end

 

Edited by Eikichi
Link to comment
Share on other sites

  • 9 months later...

Ciao ragazzi è da un po che cerco di inserire questo minigioco, e con la total conversion funziona ma...

non mi setta al termine della partita la variabile indicata su 1 o 2 e così non so come far sapere al VX se ho vinto o perso... voi sapete perchè? Ho provato a smanettarci ma sembrerebbe ok, dice:

 

if piezac == 420/@piezasi*420/@piezasi

$game_variables[@vid] = 1

 

ma la variabile che ho settato (81) in:

 

#$scene = Scene_Puzle.new(140, "Puzle1", 81, 30, "Back")

 

quando inserisco la condizione rimane sempre a 0.

Link to comment
Share on other sites

RIsolto! Non è un problema di script.

Ho inserito un "wait" fra la fine dello script e l'invio del messaggio di vittoria o sconfitta sullo schermo.

Non so perchè ma settava la variabile in ritardo rispetto all'uscita del messaggio al termine del puzzle... forse un problema della total conversion...

Link to comment
Share on other sites

  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...