Code:
#-----------------------------------------------------------------
# Slipknot's Numbers
#-----------------------------------------------------------------
class Slipknot_Game
#-----------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#-----------------------------------------------------------------
def main
@spriteset = Spriteset_Map.new; bor = 8
a="Bet "; b=$data_system.words.gold
s1=a+"500 "+b; s2=a+"1000 "+b
s3=a+"1500 "+b; s4=a+"2000 "+b
s5="Cancel"
t1="Hight"; t2="Low"
@com = Window_Command.new(160,[s1,s2,s3,s4,s5])
@com.index = @menu_index; @com.x = bor; @com.y = bor; can
@numw1 = Numwin.new
@numw1.x = 320 - @numw1.width/2
@numw1.y = 240 - @numw1.height
@numw2 = Numwin.new
@numw2.x = @numw1.x; @numw2.y = @numw1.y
@how = Window_Command.new(100,[t1,t2])
visacc(@how,false)
@how.x = 320 - @how.width/2
@how.y = @numw1.y+@numw1.height
@win = Win.new
@win.x = 320 - @win.width/2
@win.y = @how.y
@gold = Window_Gold.new
@gold.x = bor
@gold.y = @com.height + bor
Graphics.transition
loop do
Graphics.update; Input.update; update
if $scene != self; break; end
end
Graphics.freeze; @spriteset.dispose
@com.dispose; @numw1.dispose
@numw2.dispose; @how.dispose
@gold.dispose
end
#-----------------------------------------------------------------
def update
@com.update; @numw1.update
@numw2.update; @how.update
@gold.update
if @com.active; update_com; return; end
if @how.active; update_how; return; end
end
#-----------------------------------------------------------------
def delay(seconds)
for i in 0...(seconds*1)
sleep 0.01; Graphics.update
end
end
#-----------------------------------------------------------------
def can
@com.refresh
gold = $game_party.gold
if gold < 500; @com.disable_item(0); @com.disable_item(1)
@com.disable_item(2); @com.disable_item(3); @dis = 1
elsif gold == 500..999; @com.disable_item(1)
@com.disable_item(2); @com.disable_item(3); @dis = 2
elsif gold == 1000..1499; @com.disable_item(2)
@com.disable_item(3); @dis = 3
elsif gold == 1500..1999; @com.disable_item(3)
@dis = 4
else; @dis = 0; end
end
#-----------------------------------------------------------------
def visacc(w,tf)
w.visible = tf; w.active = tf
end
#-----------------------------------------------------------------
def update_com
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 @com.index
when 0
if @dis == 1
$game_system.se_play($data_system.buzzer_se); return
end; @bet = 500; comacc
when 1
if @dis == 2
$game_system.se_play($data_system.buzzer_se); return
end; @bet = 1000; comacc
when 2
if @dis == 2 or @dis == 3
$game_system.se_play($data_system.buzzer_se); return
end; @bet = 1500; comacc
when 3
if @dis == 2 or @dis == 3 or @dis == 4
$game_system.se_play($data_system.buzzer_se); return
end; @bet = 2000; comacc
when 4; $scene = Scene_Map.new
end; return
end
end
#-----------------------------------------------------------------
def update_how
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
visacc(@how,false)
@numw1.visible = false; @com.active = true
end
if Input.trigger?(Input::C)
case @how.index
when 0; howacc
when 1; howacc
end; return
end
end
#-----------------------------------------------------------------
def comacc
$game_system.se_play($data_system.decision_se)
@com.active = false
@number1 = rand(9)
@number2 = rand(9)
@numw1.visible = true
@numw1.ref(@number1.to_s)
visacc(@how,true)
end
#-----------------------------------------------------------------
def howacc
visacc(@how,false)
@numw1.visible = false
@numw2.ref(@number2.to_s)
@numw2.visible = true
if @how.index == 0
if @number2 > @number1; sys(0)
elsif @number2 == @number1; sys(1)
else; sys(2); end
elsif @how.index == 1
if @number2 < @number1; sys(0)
elsif @number2 == @number1; sys(1)
else; sys(2); end
end
@win.visible = true
can; delay(40); @win.visible = false
@numw2.visible = false; @com.active = true
end
#-----------------------------------------------------------------
def sys(a)
case a
when 0; @win.ref("WIN")
$game_party.gain_gold(@bet*2); @gold.refresh
when 1; @win.ref("DRAW")
when 2;@win.ref("LOSE")
$game_party.lose_gold(@bet); @gold.refresh
end
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
class Numwin < Window_Base
#-----------------------------------------------------------------
def initialize
super(0,0,68,68)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.visible = false; self.contents.font.size = 36
ref("!")
end
#-----------------------------------------------------------------
def ref(txt)
self.contents.clear; self.contents.draw_text(0,0,36,36,txt,1)
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
class Win < Window_Base
#-----------------------------------------------------------------
def initialize
super(0,0,96,64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.visible = false; self.contents.font.size = 32
ref("")
end
#-----------------------------------------------------------------
def ref(txt)
self.contents.clear; self.contents.draw_text(0,0,64,32,txt,1)
end
#-----------------------------------------------------------------
end