Class: Gosu::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/games_and_rpg_paradise/games/modifications/gosu/window.rb

Overview

Gosu::Window

Instance Method Summary collapse

Instance Method Details

#gosu_button_down?Boolean

#

gosu_button_down?

#

Returns:

  • (Boolean)


86
87
88
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 86

def gosu_button_down?
  button_down?(::Gosu::KbSpace)
end

#image(i, hash = { tileable: true }) ⇒ Object

#

image (image tag, img tag)

#


118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 118

def image(
    i,
    hash = {
      tileable: true
    }
  )
  this_image = ::Gosu::Image.new(
    i, hash
  )
  @array_images << this_image
  return this_image
end

#image10?Boolean

#

image10?

#

Returns:

  • (Boolean)


207
208
209
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 207

def image10?
  @array_images[9]
end

#image1?Boolean

#

image1?

#

Returns:

  • (Boolean)


144
145
146
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 144

def image1?
  @array_images[0]
end

#image2?Boolean

#

image2?

#

Returns:

  • (Boolean)


151
152
153
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 151

def image2?
  @array_images[1]
end

#image3?Boolean

#

image3?

#

Returns:

  • (Boolean)


158
159
160
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 158

def image3?
  @array_images[2]
end

#image4?Boolean

#

image4?

#

Returns:

  • (Boolean)


165
166
167
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 165

def image4?
  @array_images[3]
end

#image5?Boolean

#

image5?

#

Returns:

  • (Boolean)


172
173
174
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 172

def image5?
  @array_images[4]
end

#image6?Boolean

#

image6?

#

Returns:

  • (Boolean)


179
180
181
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 179

def image6?
  @array_images[5]
end

#image7?Boolean

#

image7?

#

Returns:

  • (Boolean)


186
187
188
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 186

def image7?
  @array_images[6]
end

#image8?Boolean

#

image8?

#

Returns:

  • (Boolean)


193
194
195
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 193

def image8?
  @array_images[7]
end

#image9?Boolean

#

image9?

#

Returns:

  • (Boolean)


200
201
202
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 200

def image9?
  @array_images[8]
end

#on_left_arrow_pressed?(&block) ⇒ Boolean

#

on_left_arrow_pressed?

#

Returns:

  • (Boolean)


61
62
63
64
65
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 61

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?

#

Returns:

  • (Boolean)


52
53
54
55
56
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 52

def on_right_arrow_pressed?(&block)
  if block_given? and ::Gosu.button_down? Gosu::KB_RIGHT
    yield
  end
end

#q_means_quitObject 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.

#


108
109
110
111
112
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 108

def q_means_quit
  if ::Gosu.button_down? Gosu::KbQ
    close
  end
end

#resetObject

#

reset (reset tag)

#


134
135
136
137
138
139
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 134

def reset
  # ======================================================================= #
  # === @array_images
  # ======================================================================= #
  @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)
#


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 32

def set_font(i)
  font_size = 30
  font_name = nil
  if i and i.is_a? Symbol
    # ===================================================================== #
    # Dynamically "re-convert" the Symbols next - the symbol may look
    # like :hack_20.
    # ===================================================================== #
    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.

#


20
21
22
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 20

def set_title(i)
  self.caption = i
end

#sqrt(i) ⇒ Object

#

sqrt

#


79
80
81
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 79

def sqrt(i)
  Math.sqrt(i)
end

#tab_key?(id) ⇒ Boolean

#

tab_key?

Whether the tab-key was pressed.

#

Returns:

  • (Boolean)


72
73
74
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 72

def tab_key?(id)
  id == Gosu::KB_TAB
end

#write_this_text(text = 'Foo Bar', font_to_use = 'Arial', font_size = 40) ⇒ Object

#

write_this_text

#


93
94
95
96
97
98
99
100
# File 'lib/games_and_rpg_paradise/games/modifications/gosu/window.rb', line 93

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