Class: RoadToRubykaigi::Sprite::Deadline
- Defined in:
- lib/road_to_rubykaigi/sprite/deadline.rb
Constant Summary collapse
- DEADLINE_SPEED =
0.3- DEADLINE_START_X =
{ 2025 => 18, 2026 => 48 }
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #activate(player_x:) ⇒ Object
- #bounding_box ⇒ Object
- #build_buffer(offset_x:) ⇒ Object
- #find {|self || nil| ... } ⇒ Object
- #simulate_physics ⇒ Object
Methods inherited from Sprite
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
7 8 9 |
# File 'lib/road_to_rubykaigi/sprite/deadline.rb', line 7 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
7 8 9 |
# File 'lib/road_to_rubykaigi/sprite/deadline.rb', line 7 def width @width end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
7 8 9 |
# File 'lib/road_to_rubykaigi/sprite/deadline.rb', line 7 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
7 8 9 |
# File 'lib/road_to_rubykaigi/sprite/deadline.rb', line 7 def y @y end |
Instance Method Details
#activate(player_x:) ⇒ Object
37 38 39 |
# File 'lib/road_to_rubykaigi/sprite/deadline.rb', line 37 def activate(player_x:) @waiting = false if player_x > DEADLINE_START_X[RoadToRubykaigi.version] end |
#bounding_box ⇒ Object
33 34 35 |
# File 'lib/road_to_rubykaigi/sprite/deadline.rb', line 33 def bounding_box { x: @x, y: @y, width: @width, height: @height } end |
#build_buffer(offset_x:) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/road_to_rubykaigi/sprite/deadline.rb', line 22 def build_buffer(offset_x:) buffer = Array.new(Map::VIEWPORT_HEIGHT) { Array.new(Map::VIEWPORT_WIDTH) { "" } } relative_x = @x - offset_x - 1 relative_y = @y - 1 @height.times do |i| next if relative_x < 1 buffer[relative_y+i][relative_x] = ANSI::RED + "#" + ANSI::DEFAULT_TEXT_COLOR end buffer end |
#find {|self || nil| ... } ⇒ Object
9 10 11 |
# File 'lib/road_to_rubykaigi/sprite/deadline.rb', line 9 def find yield self || nil end |
#simulate_physics ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/road_to_rubykaigi/sprite/deadline.rb', line 13 def simulate_physics return unless active? now = Time.now if (now - @last_update) > DEADLINE_SPEED @x += 1 @last_update = now end end |