Class: Gosu::Window
- Inherits:
-
Object
show all
- Defined in:
- lib/games_paradise/modifications/gosu/window.rb
Overview
Direct Known Subclasses
GameWindow, GamesParadise::Billiard::GameWindow, GamesParadise::DuckHuntCalculatorGame, GamesParadise::GUI::Foobar, GamesParadise::GUI::GameWindow1010, GamesParadise::GUI::HangmanGameWindow, GamesParadise::GUI::Memory::Game, GamesParadise::GUI::Sokoban::Game, GamesParadise::GameWindow, GamesParadise::Game_Window, GamesParadise::HelloWorld, GamesParadise::ParticleSimulator::Simulation, GamesParadise::Shoot, GamesParadise::Tetris::GameWindow, MainWindow, MovingTriangle
Instance Method Summary
collapse
Instance Method Details
85
86
87
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 85
def gosu_button_down?
button_down?(::Gosu::KbSpace)
end
|
#image(i, hash = {
tileable: true
}) ⇒ Object
#
image (image tag, img tag)
#
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 117
def image(
i,
hash = {
tileable: true
}
)
this_image = ::Gosu::Image.new(
i, hash
)
@array_images << this_image
return this_image
end
|
#image10? ⇒ Boolean
203
204
205
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 203
def image10?
@array_images[9]
end
|
#image1? ⇒ Boolean
140
141
142
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 140
def image1?
@array_images[0]
end
|
#image2? ⇒ Boolean
147
148
149
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 147
def image2?
@array_images[1]
end
|
#image3? ⇒ Boolean
154
155
156
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 154
def image3?
@array_images[2]
end
|
#image4? ⇒ Boolean
161
162
163
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 161
def image4?
@array_images[3]
end
|
#image5? ⇒ Boolean
168
169
170
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 168
def image5?
@array_images[4]
end
|
#image6? ⇒ Boolean
175
176
177
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 175
def image6?
@array_images[5]
end
|
#image7? ⇒ Boolean
182
183
184
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 182
def image7?
@array_images[6]
end
|
#image8? ⇒ Boolean
189
190
191
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 189
def image8?
@array_images[7]
end
|
#image9? ⇒ Boolean
196
197
198
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 196
def image9?
@array_images[8]
end
|
#on_left_arrow_pressed?(&block) ⇒ Boolean
#
on_left_arrow_pressed?
#
60
61
62
63
64
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 60
def on_left_arrow_pressed?(&block)
if block_given? and Gosu.button_down? Gosu::KB_LEFT
yield
end
end
|
#on_right_arrow_pressed?(&block) ⇒ Boolean
#
on_right_arrow_pressed?
#
51
52
53
54
55
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 51
def on_right_arrow_pressed?(&block)
if block_given? and ::Gosu.button_down? Gosu::KB_RIGHT
yield
end
end
|
#q_means_quit ⇒ Object
Also known as:
exit_on_q, exit_on_q_button_press_event
#
q_means_quit
This will exit when the user presses the q-button. Call this from within the update() method.
#
107
108
109
110
111
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 107
def q_means_quit
if ::Gosu.button_down? Gosu::KbQ
close
end
end
|
#reset ⇒ Object
133
134
135
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 133
def reset
@array_images = []
end
|
#set_font(i) ⇒ Object
Also known as:
return_font, set_use_this_font
#
set_font
Usage example:
@font = set_font(:hack_20)
#
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 31
def set_font(i)
font_size = 30
font_name = nil
if i and i.is_a? Symbol
splitted = i.to_s.split('_')
font_name = splitted.first
font_size = splitted.last.to_i
end
font = Gosu::Font.new(font_size, name: font_name)
return font
end
|
#set_title(i) ⇒ Object
#
set_title
This method can be used to set the title of a Gosu::Window instance.
#
19
20
21
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 19
def set_title(i)
self.caption = i
end
|
#sqrt(i) ⇒ Object
78
79
80
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 78
def sqrt(i)
Math.sqrt(i)
end
|
#tab_key?(id) ⇒ Boolean
#
tab_key?
Whether the tab-key was pressed.
#
71
72
73
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 71
def tab_key?(id)
id == Gosu::KB_TAB
end
|
#write_this_text(text = 'Foo Bar', font_to_use = 'Arial', font_size = 40) ⇒ Object
92
93
94
95
96
97
98
99
|
# File 'lib/games_paradise/modifications/gosu/window.rb', line 92
def write_this_text(
text = 'Foo Bar',
font_to_use = 'Arial',
font_size = 40
)
text = ::Gosu::Image.from_text(text, font_to_use, font_size)
text.draw(width/2 - 90, height/2 - 20, 0, 1, 1)
end
|