Class: RoadToRubykaigi::Sprite::Attack

Inherits:
RoadToRubykaigi::Sprite show all
Defined in:
lib/road_to_rubykaigi/sprite/attack.rb

Constant Summary collapse

SYMBOL =
""
SPEED =
3

Instance Method Summary collapse

Instance Method Details

#bounding_boxObject



66
67
68
# File 'lib/road_to_rubykaigi/sprite/attack.rb', line 66

def bounding_box
  { x: @x, y: @y, width: SYMBOL.size, height: 1 }
end

#charactersObject



57
58
59
# File 'lib/road_to_rubykaigi/sprite/attack.rb', line 57

def characters
  super { SYMBOL.chars }
end

#moveObject



53
54
55
# File 'lib/road_to_rubykaigi/sprite/attack.rb', line 53

def move
  @x += @direction * SPEED
end

#reach_border?(map, offset_x:) ⇒ Boolean



61
62
63
64
# File 'lib/road_to_rubykaigi/sprite/attack.rb', line 61

def reach_border?(map, offset_x:)
  (@x - offset_x + SYMBOL.size - 1) > Map::VIEWPORT_WIDTH ||
    (@x + SYMBOL.size) > map.width
end