-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcountrystate.rb
103 lines (82 loc) · 2.63 KB
/
countrystate.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
class CountryState
def initialize
@buttons = [Button.new(0, 0, 500, "res/american_propaganda_n.png", "res/american_propaganda_s.png"),
Button.new(0, 0, 500, "res/ussr_propaganda_n.png", "res/ussr_propaganda_s.png"),
Button.new(0, 0, 500, "res/button_n.png", "res/button_s.png")]
@buttons[0].x = $game.settings.default_width / 2 - @buttons[0].width - 75
@buttons[0].y = 100
@buttons[1].x = $game.settings.default_width / 2 + 75
@buttons[1].y = 100
@buttons[2].text = "Go Menu"
@buttons[2].x = 5
@buttons[2].y = $game.settings.default_height - @buttons[2].height - 5
@songs = [Song.new("res/United States of America National Anthem (Instrumental).mp3"),
Song.new("res/Soviet_Anthem_Instrumental_1955.mp3")]
@songs.each { |song| song.volume = 0.2 }
@next_country = nil
@go_to_menu = false
end
def update
if Fader::faded_in? and !@go_to_menu then
Fader::fade_out(10)
elsif Fader::faded_in? and @go_to_menu then
$game.state = :menu
end
if @buttons[2].clicked? then
Fader::fade_in(10)
@go_to_menu = true
end
i = 0
@buttons.each do |button|
if button.hover? and i < 2 and !@go_to_menu and $game.state != :menu then
@songs[i].play if !@songs[i].playing?
@songs[i].volume = ($game.settings.music_volume / 100.0)
else
@songs[i].stop if i < 2
end
if button.clicked? and i < 2 then
Fader::fade_in(10)
if i == 0 then
@next_country = :usa
# $game.states[:game].set_spaceship_country(:usa)
else
@next_country = :ussr
# $game.states[:game].set_spaceship_country(:ussr)
end
end
i += 1
end if @next_country == nil
=begin
if @songs[0].playing? or @songs[1].playing? then
$menus_channel.pause() if !$menus_channel.paused?
else
$menus_channel.resume() if $menus_channel.paused?
end
=end
if Fader::faded_in?() and @next_country != nil
$game.states[:selector].set_country(@next_country)
$game.state = :selector
end
end
def draw
StarAnimation.draw
$font.draw("Choose your country :",
($game.settings.default_width - $font.text_width("Choose your country :", 0.5)) / 2,
10,
500, 0.5, 0.5,
Color::RED)
i = 0
@buttons.each do |button|
button.draw
i += 1
end
end
def reset
@next_country = nil
@go_to_menu = false
@songs.each { |song| song.stop() }
end
def set_volume
@songs.each { |song| song.volume = (100.0 / $game.settings.music_volume) }
end
end