Class: Core::Game::Tile

Inherits:
Object show all
Defined in:
lib/game/map/tile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#propertiesObject (readonly)

Returns the value of attribute properties.



8
9
10
# File 'lib/game/map/tile.rb', line 8

def properties
  @properties
end

#xObject

Returns the value of attribute x.



9
10
11
# File 'lib/game/map/tile.rb', line 9

def x
  @x
end

#yObject

Returns the value of attribute y.



9
10
11
# File 'lib/game/map/tile.rb', line 9

def y
  @y
end

#zObject

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

Returns:

  • (Boolean)


29
30
31
# File 'lib/game/map/tile.rb', line 29

def passable?
  return @passable
end