Class: Core::Game::Tile
Instance Attribute Summary collapse
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
-
#z ⇒ Object
Returns the value of attribute z.
Instance Method Summary collapse
- #draw(x, y) ⇒ Object
-
#initialize(sprite, x, y, z, props = []) ⇒ Tile
constructor
A new instance of Tile.
- #passable? ⇒ Boolean
Constructor Details
#initialize(sprite, x, y, z, props = []) ⇒ Tile
Returns a new instance of Tile.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/game/map/tile.rb', line 11 def initialize(sprite, x, y, z, props=[]) @sprite = sprite @x, @y, @z = x, y, z if props[:collide] @passable = !props[:collide].to_b else @passable = true end @properties = props end |
Instance Attribute Details
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
8 9 10 |
# File 'lib/game/map/tile.rb', line 8 def properties @properties end |
#x ⇒ Object
Returns the value of attribute x.
9 10 11 |
# File 'lib/game/map/tile.rb', line 9 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
9 10 11 |
# File 'lib/game/map/tile.rb', line 9 def y @y end |
#z ⇒ Object
Returns the value of attribute z.
9 10 11 |
# File 'lib/game/map/tile.rb', line 9 def z @z end |
Instance Method Details
#draw(x, y) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/game/map/tile.rb', line 22 def draw(x, y) if @x + x + 32 < 0 or @y + y + 32 < 0 or @x + x >1024 or @y + y > 768 return end @sprite.draw(@x+x, @y+y, @z) end |
#passable? ⇒ Boolean
29 30 31 |
# File 'lib/game/map/tile.rb', line 29 def passable? return @passable end |