Sign in to follow this  
Followers 0
Fegarur

Puzzle

6 posts in this topic

Descripción:
Minijuego en el que hay que completar un puzzle colocando las piezas donde corresponde.

Recursos Necesarios:
# Foto de 420 x 420
Ej:[spoiler]user posted image[/spoiler]
# Background/Fondo
Ej:[spoiler]user posted image[/spoiler]
Screen:
[spoiler]user posted image[/spoiler]
Script:
[spoiler]
CODE
#==============================================================================
# ■ Scene_Puzle - By DarkRog - Versión Pase automático de piezas.
=begin
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 imagen 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.
=end
#------------------------------------------------------------------------------

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)
#Font:
self.contents.font.name = "Lucida Console"
self.contents.font.size = 25
@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
if @back != false
self.contents.blt(0, 0, RPG::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, "Piezas")
self.contents.draw_text(300, 0, 640, 32, "Panel")
if @timeh != false
if @time/25%60 > 9
self.contents.draw_text(460, 0, 640, 32, "Tiempo: #{@time/25/60}:#{@time/25%60}")
else
self.contents.draw_text(460, 0, 640, 32, "Tiempo: #{@time/25/60}:0#{@time/25%60}")
end
else
self.contents.draw_text(420, 0, 640, 32, "Tiempo Ilimitado")
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, RPG::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, RPG::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), RPG::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), RPG::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, RPG::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)
end
if Input.repeat?(Input::LEFT) and @cursorx > 0
@cursorx -= 1
$game_system.se_play($data_system.cursor_se)
end
if Input.repeat?(Input::DOWN) and @cursory < 420/@piezasi-1
@cursory += 1
$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)
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 = $fontsize
self.opacity = 0
refresh(0)
end
def refresh(o)
self.contents.clear
self.contents.fill_rect(175, 35, 422, 422, Color.new(255, 255, 255, o))
end
end
[/spoiler]
Instrucciones:
user posted image Se necesita una imagen de 420 x 420 que será la imagen del puzzle.
user posted image También se puede necesitar una imagen de fondo, un 'background'.
user posted image Para usarlo, utiliza en Llamar Script:
QUOTE
$scene = Scene_Puzle.new(tamaño de las piezas, "nombre de la imagen", ID de la variable, tiempo, "nombre del fondo")

# El tamaño de las piezas tiene que ser divisible por 420.
# La variable tandrá valor 1 si se gana, y 2 si se acaba el tiempo.
# Si no quieres que haya tiempo, pon 'false' (sin comillas) en su lugar. Si quieres establecer un tiempo, va en segundos.
# Si no quieres fondo, pon 'false' en su lugar.


Crédito:
Script creado por DarkRog. Edited by Fegarur
0

Share this post


Link to post
Share on other sites
Ele que chulo muy buen aporte fegarur ^^
pero una pregunta el puzzle que hay que formar de deonde lo sacas y donde ay que ponerlo?
0

Share this post


Link to post
Share on other sites
La imagen tiene que tener un tamaño de 420x420 y la tienes que sacar tú de donde quieras. xD.png
No me he fijado en el script, pero supongo que irá en Pictures. Puedes probar. icon13.gif Edited by Fegarur
0

Share this post


Link to post
Share on other sites
fegarur pon otra vez el script que lo necesito.
0

Share this post


Link to post
Share on other sites
buneo foro podrian explicar este tema paso a paso que creo que muchos tenemos problrmas con el
0

Share this post


Link to post
Share on other sites
Creo que lo mejor es que nos digas en qué tienes problemas exactamente para resolverlos. icon13.gif
0

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0