Class: PositionComponent
- Inherits:
-
Object
- Object
- PositionComponent
- Defined in:
- lib/delve/component/position.rb
Instance Method Summary collapse
- #displace(dx, dy) ⇒ Object
- #id ⇒ Object
-
#initialize(parent) ⇒ PositionComponent
constructor
A new instance of PositionComponent.
- #set(x, y) ⇒ Object
- #x ⇒ Object
- #y ⇒ Object
Constructor Details
#initialize(parent) ⇒ PositionComponent
Returns a new instance of PositionComponent.
2 3 4 5 6 7 |
# File 'lib/delve/component/position.rb', line 2 def initialize(parent) raise 'Cannot create position comonent when parent is nil' unless parent @x = 0 @y = 0 end |
Instance Method Details
#displace(dx, dy) ⇒ Object
26 27 28 29 |
# File 'lib/delve/component/position.rb', line 26 def displace(dx, dy) @x += dx @y += dy end |
#id ⇒ Object
9 10 11 |
# File 'lib/delve/component/position.rb', line 9 def id :position end |
#set(x, y) ⇒ Object
21 22 23 24 |
# File 'lib/delve/component/position.rb', line 21 def set(x, y) @x = x @y = y end |
#x ⇒ Object
13 14 15 |
# File 'lib/delve/component/position.rb', line 13 def x @x end |
#y ⇒ Object
17 18 19 |
# File 'lib/delve/component/position.rb', line 17 def y @y end |