-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselectorstate.rb
139 lines (108 loc) · 3.99 KB
/
selectorstate.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
class SelectorState
def initialize
@just_entered = true
@selector_bars = {
ussr: SelectorBar.new(256, "Soyouz X9", "Soyouz X10"),
usa: SelectorBar.new(256, "Nasa Falcon I", "Nasa Falcon II")
}
@specs = {
"Soyouz X9" => {
"speed": 2,
"life": 5,
"weapon damage": 5,
"_guns": [Vec2.new(124,1), Vec2.new(255, 1)]
},
"Soyouz X10" => {
"speed": 8,
"life": 6,
"weapon damage": 3,
"_guns": [Vec2.new(19, 204), Vec2.new(329, 303)]
},
"Nasa Falcon I" => {
"speed": 4,
"life": 4,
"weapon damage": 3,
"_guns": [Vec2.new(196, 0), Vec2.new(355, 0)]
},
"Nasa Falcon II" => {
"speed": 5,
"life": 5,
"weapon damage": 3,
"_guns": [Vec2.new(132, 3), Vec2.new(256, 3)]
}
}
@next_country = nil
@next_state = nil
@buttons = []
button = Button.new(0, 0, 500, "res/button_n.png", "res/button_s.png")
1.times { @buttons << button }
@buttons[0].text = "Go back"
@buttons[0].x = 5
@buttons[0].y = $game.settings.default_height - @buttons[0].height - 5
end
def update
@selector_bars[@next_country].update()
# For quitting state
if bc = @buttons[0].clicked? or button_down?(Gosu::KbReturn)
if Fader::faded_out? and @next_state == nil
# $game.states[:game].set_spaceship_country(@next_country)
@next_state = (bc) ? :country : :game
if @next_state == :game
$menus_channel.stop if $menus_channel != nil
$game.states[:game].set_spaceship(@next_country,
@selector_bars[@next_country].current_element,
@specs[@selector_bars[@next_country].current_element])
end
Fader::fade_in(10)
end
end if !@selector_bars[@next_country].moving
if @next_state != nil and Fader::faded_in?
$game.state = @next_state
end
end
def draw
StarAnimation::draw($game.width/2-(@selector_bars[@next_country].x / 3.0))
@selector_bars[@next_country].draw()
@buttons.each { |button| button.draw() }
# GUI
Gosu.draw_rect($game.settings.default_width - 420,
0,
420,
$game.settings.default_height,
Gosu::Color.new(220, 0, 0, 0),
500)
$font.draw(@selector_bars[@next_country].current_element,
$game.settings.default_width - 420,
10,
500,
0.4,
0.4,
Gosu::Color::YELLOW)
spec_y = 80
@specs[@selector_bars[@next_country].current_element].each do |key, spec|
next if key[0] == "_"
$font.draw("#{key} : #{spec}",
$game.settings.default_width - 420,
spec_y,
500,
0.3,
0.35)
spec_y += 22
end
$font.draw("Press enter to begin...",
$game.settings.default_width - 400,
$game.settings.default_height - 50,
500,
0.25,
0.30)
end
def reset
@just_entered = true
@next_state = nil
@selector_bars.each { |_, sb| sb.reset }
end
def set_volume; end
def set_country(c)
@next_country = c
end
end