Class: Termfront::DropItem::Base
- Inherits:
-
Object
- Object
- Termfront::DropItem::Base
- Defined in:
- lib/termfront/drop_item/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #in_range?(px, py) ⇒ Boolean
-
#initialize(x:, y:) ⇒ Base
constructor
A new instance of Base.
- #pickup!(player) ⇒ Object
- #sprite_color ⇒ Object
Constructor Details
#initialize(x:, y:) ⇒ Base
Returns a new instance of Base.
8 9 10 11 |
# File 'lib/termfront/drop_item/base.rb', line 8 def initialize(x:, y:) @x = x @y = y end |
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x.
6 7 8 |
# File 'lib/termfront/drop_item/base.rb', line 6 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
6 7 8 |
# File 'lib/termfront/drop_item/base.rb', line 6 def y @y end |
Instance Method Details
#in_range?(px, py) ⇒ Boolean
13 14 15 |
# File 'lib/termfront/drop_item/base.rb', line 13 def in_range?(px, py) (px - @x)**2 + (py - @y)**2 < Config::PICKUP_RADIUS**2 end |
#pickup!(player) ⇒ Object
17 18 19 |
# File 'lib/termfront/drop_item/base.rb', line 17 def pickup!(player) raise NotImplementedError end |
#sprite_color ⇒ Object
21 22 23 |
# File 'lib/termfront/drop_item/base.rb', line 21 def sprite_color raise NotImplementedError end |