Class: MiniGL::GameWindow
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- MiniGL::GameWindow
- Defined in:
- lib/minigl/global.rb
Overview
The main class for a MiniGL game, holds references to globally accessible objects and constants.
Instance Method Summary collapse
-
#clear(color) ⇒ Object
Draws a rectangle with the size of the entire screen, in the given color.
-
#initialize(scr_w, scr_h, fullscreen = true, gravity = Vector.new(0, 1), min_speed = Vector.new(0.01, 0.01), ramp_contact_threshold = 10, ramp_slip_threshold = 1.2, kb_held_delay = 40, kb_held_interval = 5, double_click_delay = 8) ⇒ GameWindow
constructor
Creates a game window (initializing a game with all MiniGL features enabled).
Constructor Details
#initialize(scr_w, scr_h, fullscreen = true, gravity = Vector.new(0, 1), min_speed = Vector.new(0.01, 0.01), ramp_contact_threshold = 10, ramp_slip_threshold = 1.2, kb_held_delay = 40, kb_held_interval = 5, double_click_delay = 8) ⇒ GameWindow
Creates a game window (initializing a game with all MiniGL features enabled).
Parameters:
- scr_w
-
Width of the window, in pixels.
- scr_h
-
Height of the window, in pixels.
- fullscreen
-
Whether the window must be initialized in full screen mode.
- gravity
-
A Vector object representing the horizontal and vertical components of the force of gravity. Essentially, this force will be applied to every object which calls
move, from the Movement module. - min_speed
-
A Vector with the minimum speed for moving objects, i.e., the value below which the speed will be rounded to zero.
- ramp_contact_threshold
-
The maximum horizontal movement an object can perform in a single frame and keep contact with a ramp when it’s above one.
- ramp_slip_threshold
-
The maximum ratio between height and width of a ramp above which the objects will always slip down when trying to ‘climb’ that ramp.
- kb_held_delay
-
The number of frames a key must be held by the user before the “held” event (that can be checked with
KB.key_held?) starts to trigger. - kb_held_interval
-
The interval, in frames, between each triggering of the “held” event, after the key has been held for more than
kb_held_delayframes. - double_click_delay
-
The maximum interval, in frames, between two clicks, to trigger the “double click” event (checked with
Mouse.double_click?).
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/minigl/global.rb', line 190 def initialize(scr_w, scr_h, fullscreen = true, gravity = Vector.new(0, 1), min_speed = Vector.new(0.01, 0.01), ramp_contact_threshold = 10, ramp_slip_threshold = 1.2, kb_held_delay = 40, kb_held_interval = 5, double_click_delay = 8) super scr_w, scr_h, fullscreen G.window = self G.gravity = gravity G.min_speed = min_speed G.ramp_contact_threshold = ramp_contact_threshold G.ramp_slip_threshold = ramp_slip_threshold G.kb_held_delay = kb_held_delay G.kb_held_interval = kb_held_interval G.double_click_delay = double_click_delay KB.initialize Mouse.initialize Res.initialize end |
Instance Method Details
#clear(color) ⇒ Object
Draws a rectangle with the size of the entire screen, in the given color.
Parameters:
- color
-
Color of the rectangle to be drawn.
212 213 214 215 216 217 |
# File 'lib/minigl/global.rb', line 212 def clear(color) draw_quad 0, 0, color, width, 0, color, width, height, color, 0, height, color, 0 end |