Class: GamesParadise::GUI::HangmanGameWindow
Constant Summary
collapse
- WIDTH =
880
- HEIGHT =
880
Class Method Summary
collapse
-
.[](i = '') ⇒ Object
# === GamesParadise::GUI::Hangman[] ========================================================================= #.
Instance Method Summary
collapse
Methods included from BaseModule
#cliner, #commandline_arguments?, #first_argument?, #infer_the_namespace, #namespace?, #rename_file, #reset_the_internal_hash, #return_pwd, #set_commandline_arguments
#gosu_button_down?, #image, #image10?, #image1?, #image2?, #image3?, #image4?, #image5?, #image6?, #image7?, #image8?, #image9?, #on_left_arrow_pressed?, #on_right_arrow_pressed?, #q_means_quit, #set_font, #set_title, #sqrt, #tab_key?, #write_this_text
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ HangmanGameWindow
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 42
def initialize(
commandline_arguments = nil,
run_already = true
)
super(WIDTH, HEIGHT, false)
reset
set_title 'The Hangman Game'
set_commandline_arguments(
commandline_arguments
)
run if run_already
end
|
Class Method Details
.[](i = '') ⇒ Object
#
GamesParadise::GUI::Hangman[]
#
229
230
231
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 229
def self.[](i = '')
new(i)
end
|
Instance Method Details
#check_whether_that_character_is_part_of_the_hangman(i = @old_character) ⇒ Object
#
check_whether_that_character_is_part_of_the_hangman
#
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 204
def check_whether_that_character_is_part_of_the_hangman(
i = @old_character
)
if @game.is_this_character_included?(i)
e 'Yes, the character '+i+' is included.'
else if is_the_game_over?
e ::Colours.steelblue('GAME OVER!!!')
disable_user_input
do_display_game_over_banner
end
progress_the_frame_by_plus_one
end
end
|
#consider_drawing_the_game_over_text ⇒ Object
#
consider_drawing_the_game_over_text
#
160
161
162
163
164
165
166
167
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 160
def consider_drawing_the_game_over_text
if @display_the_game_over_banner
@font_smaller.draw_text(
'GAME OVER', 250, 40, 1, 1, 1,
::Gosu::COLOUR_GOLD
)
end
end
|
#correct_frame_out_of_bound_values ⇒ Object
#
correct_frame_out_of_bound_values
#
122
123
124
125
126
127
128
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 122
def correct_frame_out_of_bound_values
if @game.frame_counter? < 0
@game.frame_counter = 0
elsif @game.frame_counter? > 6
@game.frame_counter = 6
end
end
|
133
134
135
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 133
def disable_user_input
@the_user_may_input_something = false
end
|
#do_display_game_over_banner ⇒ Object
#
do_display_game_over_banner
#
222
223
224
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 222
def do_display_game_over_banner
@display_the_game_over_banner = true
end
|
#do_show_the_next_frame ⇒ Object
#
do_show_the_next_frame
#
100
101
102
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 100
def do_show_the_next_frame
@game.increment_the_frame_counter_by_plus_one
end
|
#do_show_the_previous_frame ⇒ Object
#
do_show_the_previous_frame
#
93
94
95
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 93
def do_show_the_previous_frame
@game.decrement_the_frame_counter_by_plus_one
end
|
#draw ⇒ Object
195
196
197
198
199
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 195
def draw
draw_this_frame(@game.frame_counter?)
@text_input.draw(0)
consider_drawing_the_game_over_text
end
|
#draw_this_frame(i) ⇒ Object
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 146
def draw_this_frame(i)
if i.is_a? Numeric
i = ::GamesParadise::Hangman::ARRAY_ASCII_HANGMAN_PROGRESSION[@game.frame_counter?]
end
@font.draw_text(
i,
10, 10, 0, 1.5, 1.5,
Gosu::Color::YELLOW
)
end
|
#is_the_game_over? ⇒ Boolean
115
116
117
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 115
def is_the_game_over?
@game.is_the_game_over?
end
|
#progress_the_frame_by_plus_one ⇒ Object
#
progress_the_frame_by_plus_one
#
107
108
109
110
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 107
def progress_the_frame_by_plus_one
@game.increase_the_frame_counter_by_plus_one
@game.check_for_game_over_state
end
|
#reset ⇒ Object
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
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 58
def reset
@font = set_font(:hack_30)
@font_smaller = set_font(:hack_25)
@game = ::GamesParadise::Hangman.new { :do_not_run_yet }
@game.we_may_not_exit
@the_user_may_input_something = true
@display_the_game_over_banner = false
@old_character = ''
@text_input = TextField.new(self, 300, 250)
self.text_input = @text_input
end
|
#run ⇒ Object
140
141
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 140
def run
end
|
#update ⇒ Object
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# File 'lib/games_paradise/gui/gosu/hangman/hangman.rb', line 172
def update
on_right_arrow_pressed? { do_show_the_next_frame
}
on_left_arrow_pressed? { do_show_the_previous_frame
}
q_means_quit
if @the_user_may_input_something
if @old_character == @text_input.text
else
@old_character = @text_input.text
unless @old_character.empty?
check_whether_that_character_is_part_of_the_hangman(@old_character)
end
end
correct_frame_out_of_bound_values
end
end
|