CaistsaRpg
¿Quieres reaccionar a este mensaje? Regístrate en el foro con unos pocos clics o inicia sesión para continuar.

Script Ruleta

2 participantes

Ir abajo

Script Ruleta Empty Script Ruleta

Mensaje  Caistsa Dom Mar 30, 2008 4:46 pm

Pues lo que ase el script es que crea un juego de ruleta es bueno para los casinos
3 clases nuevas encima de Main.
En un evento poneis llamar script:
Código:
$scene = Scene_Roulette.new(500, "música")
Donde pone 500 pones la apuesta máxima que quieres que se pueda poner, y en "música" la BGM que quieres que se escuche.

La primera:
Código:
class Window_Table3 < Window_Selectable

def initialize
  super(0, 64, 512, 416)
  self.contents = Bitmap.new(width - 32, height - 24)
  self.contents.font.name = $defaultfonttype
  self.contents.font.size = $defaultfontsize
  @item_max = 48
  @column_max = 3
  refresh
  self.index = 0
end
#--------------------------------------------------------------------------
def refresh

  s1 = "1-18"
  s2 = "19-36"
  s3 = ""
  s4 = "Pares"
  s5 = "Impares"
  s6 = ""
  s7 = "-1st 12-"
  s8 = "-2nd 12-"
  s9 = "-3rd 12-"
  s10 = "Columna 1"
  s11 = "Columna 2"
  s12 = "Columna 3"
 
  @commands = [s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12] 

  self.contents.clear
 
  for i in 0...@item_max
 if i < 12
  draw_item1(i)
 else
  j = i-11
  draw_item2(i,j)
 end
  end

end

def draw_item1(index)
  x = 4 + index % 3 * (160+12)
  y = index / 3 * 24
  rect = Rect.new(x, y, self.width / @column_max - 32, 24)
  self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  self.contents.draw_text(rect, @commands[index])
end

def draw_item2(index,ctr)
  x = 4 + index % 3 * (160+12)
  y = index / 3 * 24
  rect = Rect.new(x, y, self.width / @column_max - 32, 24)
  self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  self.contents.draw_text(rect, ctr.to_s)
end

def update_cursor_rect
  x = 4 + index % 3 * (160+12)
  y = index / 3 * 24
  self.cursor_rect.set(x, y, self.width / @column_max - 32, 24)
end

end

La segunda
Código:
class Window_Money < Window_Base
# ------------------------------------
def initialize
  super(512, 288, 128, 96)
  self.contents = Bitmap.new(width - 32, height - 32)
  self.contents.font.name = $defaultfonttype
  self.contents.font.size = $defaultfontsize
  @bet = 0
  refresh(@bet)
end
# ------------------------------------
def refresh(bet)
  @bet = bet
  self.contents.clear
  self.contents.font.color = normal_color
  self.contents.draw_text(0, 0, 96, 32, $game_party.gold.to_s,2)
  self.contents.draw_text(0, 32, 96, 32, @bet.to_s, 2)
end
end
Y la tercera y ultima
Código:
class Scene_Roulette
 
def initialize(max_bet, music)
  @max_bet = max_bet
  @music = music
end

def main
  $game_system.bgm_memorize
  Audio.bgm_play("Audio/BGM/"+@music, 100, 100)
  @help_window = Window_Help.new
  @table_window = Window_Table3.new
  @table_window.active = false
  @bet_window = Window_Command.new(128,["1","10","50","100","Hecho","Salir"])
  @bet_window.x = 512
  @bet_window.y = 64
  @bet_window.index = 0
  @money_window = Window_Money.new
  @money_window.y = 384
  @yesno_window = Window_Command.new(128,["Sí","No"])
  @yesno_window.active = false
  @yesno_window.visible = false
  @yesno_window.x =  256
  @yesno_window.y =  208
  @yesno_window.z =  9999
  @type = 0
  variable_init
  Graphics.transition
  loop do
 Graphics.update
 Input.update
 update
 if $scene != self
  break
 end
  end
  Graphics.freeze
  @help_window.dispose
  @table_window.dispose
  @bet_window.dispose
  @money_window.dispose
  @yesno_window.dispose
end

def update
  @table_window.update
  @bet_window.update
  @help_window.update
  @money_window.update
  @yesno_window.update
  if @bet_window.active
 update_bet
 return
  end
  if @table_window.active
 update_table
 return
  end
  if @yesno_window.active
 update_yesno
 return
  end
end

def update_bet
  @help_window.set_text("¿A qué apuestas?")
  if Input.trigger?(Input::B)
 $game_system.se_play($data_system.cancel_se)
 @bet_window.index = 5
 return
  end
  if Input.trigger?(Input::C)
 case @bet_window.index
 when 0 
  @dummybet = 1
  if ($game_party.gold >= @dummybet) and ((@currentbet+@dummybet) <= @max_bet)
  $game_system.se_play($data_system.decision_se)
  @bet = 1
  bet
  else
  $game_system.se_play($data_system.buzzer_se)
  return
  end
 when 1
  @dummybet = 10
  if ($game_party.gold >= @dummybet) and ((@currentbet+@dummybet) <= @max_bet)
  $game_system.se_play($data_system.decision_se)
  @bet = 10
  bet
  else
  $game_system.se_play($data_system.buzzer_se)
  return
  end
 when 2
  @dummybet = 50
  if ($game_party.gold >= @dummybet) and ((@currentbet+@dummybet) <= @max_bet)
  $game_system.se_play($data_system.decision_se)
  @bet = 50
  bet
  else
  $game_system.se_play($data_system.buzzer_se)
  return
  end
 when 3
  @dummybet = 100
  if ($game_party.gold >= @dummybet) and ((@currentbet+@dummybet) <= @max_bet)
  $game_system.se_play($data_system.decision_se)
  @bet = 100
  bet
  else
  $game_system.se_play($data_system.buzzer_se)
  return
  end
 when 4
  if @currentbet > 0
  $game_system.se_play($data_system.decision_se)
  @table_window.active = true
  @bet_window.active = false
  else
  $game_system.se_play($data_system.buzzer_se)
  end
 when 5
  $game_system.se_play($data_system.cancel_se)
  $game_party.gain_gold(@currentbet) 
  $scene = Scene_Map.new
  $game_system.bgm_restore
 end
  end
end

def update_table
  if Input.trigger?(Input::B)
 $game_system.se_play($data_system.cancel_se)
 @table_window.index = 5
 return
  end
  if Input.trigger?(Input::C)
 
 if @table_window.index == 0
  for i in 1...19
  @hand[i] = i
  @prize = @currentbet*2
  end
 elsif @table_window.index == 1
  for i in 1...19
  @hand[i] = i+18
  @prize = @currentbet*2
  end
 
 elsif @table_window.index == 3
  for i in 1...37
  if i%2 == 0
    @hand[i] = i
    @prize = @currentbet*2
  end
  end
 elsif @table_window.index == 4
  for i in 1...37
  if i%2 == 1
    @hand[i] = i
    @prize = @currentbet*2
  end
  end 

 elsif @table_window.index == 6
  for i in 1...13
  @hand[i] = i
  @prize = @currentbet*3
  end
 elsif @table_window.index == 7
  for i in 1...13
  @hand[i] = i+12
  @prize = @currentbet*3
  end 
 elsif @table_window.index == 8
  for i in 1...13
  @hand[i] = i+24
  @prize = @currentbet*3
  end 
 elsif @table_window.index == 9
  for i in 1...37
  if i%3 == 1
    @hand[i] = i
    @prize = @currentbet*3
  end
  end
 elsif @table_window.index == 10
  for i in 1...37
  if i%3 == 2
    @hand[i] = i
    @prize = @currentbet*3
  end
  end
 elsif @table_window.index == 11
  for i in 1...37
  if i%3 == 0
    @hand[i] = i
    @prize = @currentbet*3
  end
  end 
 
 elsif @table_window.index > 11
  @hand[1] = @table_window.index - 11
  @prize = @currentbet*36
 end
 
  @table_window.active = false
  @help_window.set_text("Girando...")
  delay(2)
  spin
 
  end
end

def update_yesno
  if Input.trigger?(Input::B)
 $game_system.se_play($data_system.cancel_se)
 $scene = Scene_Map.new
 return
  end
  if Input.trigger?(Input::C)
 case @yesno_window.index
 when 0
  variable_init
  @money_window.refresh(@currentbet)
  @yesno_window.active = false
  @yesno_window.visible = false
  @bet_window.active = true
  @bet_window.index = 0
 when 1
  $scene = Scene_Map.new
  Audio.bgm_stop
  $game_system.bgm_restore
 end
  end
end

def spin
  @same = false
  @num = rand(36)+1
  for i in 1...@hand.size
 if @num == @hand[i]
  @same = true
  break
 end
  end
  if @same == true
 win
  else
 lose
  end
end
 
def bet
  $game_party.lose_gold(@bet)
  @currentbet += @bet
  @money_window.refresh(@currentbet)
  @bet = 0
end

def variable_init
  @bet = 0
  @dummybet = 0
  @currentbet = 0
  @dummy_gold = 0
  @hand = []
  @num = 0
  @same = false
  @prize = 0
end

def win
  $game_party.gain_gold(@prize)
  @currentbet = 0
  @money_window.refresh(@currentbet)
  @help_window.set_text("El número ganador es... "+@num.to_s+", TÚ GANAS... ¿Juegas otra vez?")
  delay(1)
  playagain
end

def lose
  @currentbet = 0
  @money_window.refresh(@currentbet)
  @help_window.set_text("El número ganador es... "+@num.to_s+", TÚ PIERDES... ¿Juegas otra vez?")
  delay(1)
  playagain
end

def playagain
  @yesno_window.visible = true
  @yesno_window.active = true
  @yesno_window.index = 0
end

def delay(seconds)
  for i in 0...(seconds * 10)
 sleep 0.1
 Graphics.update
  end
end

end
Esta traducido ke lo disfruten
Si os da error en la linea 7 del primer script poned esto
Código:
$defaultfonttype = $fontface
  $defaultfontsize = $fontsize
Caistsa
Caistsa
Administrador
Administrador

Cantidad de envíos : 187
Fecha de inscripción : 21/02/2008

https://caistsarpg.superforo.net

Volver arriba Ir abajo

Script Ruleta Empty Re: Script Ruleta

Mensaje  PepDracko Dom Mar 30, 2008 9:30 pm

Holas!!

Esta bueno el script, lo usaré en algun proyecto.

PD desaparece.
avatar
PepDracko
Hijo De Artemisa
Hijo De Artemisa

Cantidad de envíos : 66
Edad : 28
Localización : In your room, above your sister
Fecha de inscripción : 10/03/2008

Volver arriba Ir abajo

Volver arriba

- Temas similares

 
Permisos de este foro:
No puedes responder a temas en este foro.