Class: Reight::Navigator
- Inherits:
-
Object
- Object
- Reight::Navigator
- Defined in:
- lib/reight/app/navigator.rb
Defined Under Namespace
Classes: Message
Instance Method Summary collapse
- #draw ⇒ Object
- #flash ⇒ Object
-
#initialize(app) ⇒ Navigator
constructor
A new instance of Navigator.
- #key_pressed ⇒ Object
- #sprites ⇒ Object
- #visible=(visible) ⇒ Object
- #visible? ⇒ Boolean
- #window_resized ⇒ Object
Constructor Details
#initialize(app) ⇒ Navigator
Returns a new instance of Navigator.
6 7 8 |
# File 'lib/reight/app/navigator.rb', line 6 def initialize(app) @app, @visible = app, true end |
Instance Method Details
#draw ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/reight/app/navigator.rb', line 25 def draw() return unless visible? fill 220 no_stroke rect 0, 0, width, Reight::App::NAVIGATOR_HEIGHT sprite(*sprites) end |
#flash ⇒ Object
10 |
# File 'lib/reight/app/navigator.rb', line 10 def flash(...) = .flash(...) |
#key_pressed ⇒ Object
33 34 35 36 |
# File 'lib/reight/app/navigator.rb', line 33 def key_pressed() index = [F1, F2, F3, F4, F5].index(key_code) [index]&.click if index end |
#sprites ⇒ Object
20 21 22 23 |
# File 'lib/reight/app/navigator.rb', line 20 def sprites() [*, *, *, ] .map &:sprite end |
#visible=(visible) ⇒ Object
12 13 14 15 16 |
# File 'lib/reight/app/navigator.rb', line 12 def visible=(visible) return if visible == @visible @visible = visible sprites.each {|sp| visible ? sp.show : sp.hide} end |
#visible? ⇒ Boolean
18 |
# File 'lib/reight/app/navigator.rb', line 18 def visible? = @visible |
#window_resized ⇒ Object
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 |
# File 'lib/reight/app/navigator.rb', line 38 def window_resized() [, , ] .flatten.map(&:sprite).each do |sp| sp.w = sp.h = Reight::App::NAVIGATOR_HEIGHT sp.y = 0 end space = Reight::App::SPACE x = space .map {_1.sprite}.each do |sp| sp.x = x + 1 x = sp.right end.tap do x += space unless _1.empty? end .map {_1.sprite}.each do |sp| sp.x = x + 1 x = sp.right end.tap do x += space unless _1.empty? end .map {_1.sprite}.each do |sp| sp.x = x + 1 x = sp.right end.tap do x += space unless _1.empty? end .sprite.tap do |sp| sp.x = x + space sp.y = 0 sp.h = Reight::App::NAVIGATOR_HEIGHT sp.right = width - space end end |