Class: PositionComponent

Inherits:
Object
  • Object
show all
Defined in:
lib/delve/component/position.rb

Instance Method Summary collapse

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

#idObject



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

#xObject



13
14
15
# File 'lib/delve/component/position.rb', line 13

def x
  @x
end

#yObject



17
18
19
# File 'lib/delve/component/position.rb', line 17

def y
  @y
end