Class: Termfront::DropItem::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/termfront/drop_item/base.rb

Direct Known Subclasses

Weapon

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#xObject

Returns the value of attribute x.



6
7
8
# File 'lib/termfront/drop_item/base.rb', line 6

def x
  @x
end

#yObject

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

Returns:

  • (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

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/termfront/drop_item/base.rb', line 17

def pickup!(player)
  raise NotImplementedError
end

#sprite_colorObject

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/termfront/drop_item/base.rb', line 21

def sprite_color
  raise NotImplementedError
end