Class: RoadToRubykaigi::Sprite::Bonuses

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/road_to_rubykaigi/sprite/bonus.rb

Constant Summary collapse

BONUSES_DATA =
{
  Basic: [
    { x: 39, y: 22, character: :ruby },
    { x: 46, y: 22, character: :ruby },
    { x: 53, y: 22, character: :ruby },
    { x: 107, y: 23, character: :coffee },
    { x: 110, y: 23, character: :book },
    { x: 142, y: 16, character: :ruby },
    { x: 146, y: 16, character: :ruby },
    { x: 205, y: 19, character: :money },
    { x: 212, y: 19, character: :money },
    { x: 205, y: 19, character: :money },
    { x: 212, y: 19, character: :money },
    { x: 223, y: 17, character: :money },
    { x: 231, y: 17, character: :money },
    { x: 243, y: 13, character: :money },
    { x: 250, y: 13, character: :money },
    { x: 260, y: 10, character: :sushi },
    { x: 265, y: 10, character: :meat },
    { x: 270, y: 10, character: :fish },
    { x: 260, y: 10, character: :sushi },
    { x: 265, y: 10, character: :meat },
    { x: 270, y: 10, character: :fish },
    { x: 275, y: 10, character: :sushi },
    { x: 280, y: 10, character: :meat },
    { x: 285, y: 10, character: :fish },
    { x: 290, y: 10, character: :sushi },
    { x: 295, y: 10, character: :meat },
    { x: 300, y: 10, character: :fish },
    { x: 358, y: 15, character: :money },
    { x: 363, y: 13, character: :money },
    { x: 368, y: 15, character: :money },
    { x: 373, y: 13, character: :money },
    { x: 378, y: 15, character: :money },
    { x: 383, y: 13, character: :money },
    { x: 388, y: 15, character: :money },
  ],
  Alcohol: [
    { x: 217, y: 28, character: :beer },
    { x: 220, y: 28, character: :beer },
    { x: 223, y: 28, character: :beer },
  ],
  Laptop: [
    { x: 298, y: 23, character: :laptop },
  ]
}

Instance Method Summary collapse

Instance Method Details

#build_buffer(offset_x:) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/road_to_rubykaigi/sprite/bonus.rb', line 55

def build_buffer(offset_x:)
  buffer = Array.new(Map::VIEWPORT_HEIGHT) { Array.new(Map::VIEWPORT_WIDTH) { "" } }
  @bonuses.each do |bonus|
    bounding_box = bonus.bounding_box
    relative_x = bounding_box[:x] - offset_x - 1
    relative_y = bounding_box[:y] - 1
    next if relative_x < 1
    bonus.characters.each_with_index do |character, j|
      next if relative_x + j >= Map::VIEWPORT_WIDTH - 1
      buffer[relative_y][relative_x+j] = character
    end
  end
  buffer
end

#updateObject



70
71
# File 'lib/road_to_rubykaigi/sprite/bonus.rb', line 70

def update
end