Class: Chronus::GameObject

Inherits:
GameModel show all
Defined in:
lib/chronus/game_object.rb

Direct Known Subclasses

GameBackground, GameSprite

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGameObject



7
8
9
10
11
12
13
14
15
# File 'lib/chronus/game_object.rb', line 7

def initialize
  @x = 0
  @y = 0
  @width = 0
  @height = 0
  @z = 0
  @visible = true
  @last_update = 0
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



6
7
8
# File 'lib/chronus/game_object.rb', line 6

def height
  @height
end

#visibleObject

Returns the value of attribute visible.



6
7
8
# File 'lib/chronus/game_object.rb', line 6

def visible
  @visible
end

#widthObject

Returns the value of attribute width.



6
7
8
# File 'lib/chronus/game_object.rb', line 6

def width
  @width
end

#xObject

Returns the value of attribute x.



6
7
8
# File 'lib/chronus/game_object.rb', line 6

def x
  @x
end

#yObject

Returns the value of attribute y.



6
7
8
# File 'lib/chronus/game_object.rb', line 6

def y
  @y
end

#zObject

Returns the value of attribute z.



6
7
8
# File 'lib/chronus/game_object.rb', line 6

def z
  @z
end

Instance Method Details

#bottomObject

Returns the bottom position



36
37
38
# File 'lib/chronus/game_object.rb', line 36

def bottom
  @y + @height
end

#hideObject



21
22
23
# File 'lib/chronus/game_object.rb', line 21

def hide
  @visible = false
end

#leftObject

Returns the left position



41
42
43
# File 'lib/chronus/game_object.rb', line 41

def left
  @x
end

#pos(x, y) ⇒ Object

Sets X and Y position



46
47
48
49
# File 'lib/chronus/game_object.rb', line 46

def pos(x, y)
  @x = x
  @y = y
end

#rightObject

Returns the right position



31
32
33
# File 'lib/chronus/game_object.rb', line 31

def right
  @x + @width
end

#showObject



17
18
19
# File 'lib/chronus/game_object.rb', line 17

def show
  @visible = true
end

#topObject

Returns the top position



26
27
28
# File 'lib/chronus/game_object.rb', line 26

def top
  @y
end