Class: Tile
- Inherits:
-
Object
- Object
- Tile
- Defined in:
- lib/gridmap.rb
Instance Attribute Summary collapse
-
#angle ⇒ Object
Returns the value of attribute angle.
-
#centre_point ⇒ Object
Returns the value of attribute centre_point.
-
#connections ⇒ Object
Returns the value of attribute connections.
-
#details ⇒ Object
Returns the value of attribute details.
-
#image ⇒ Object
Returns the value of attribute image.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
-
#z ⇒ Object
Returns the value of attribute z.
Instance Method Summary collapse
- #draw ⇒ Object
- #draw_rot ⇒ Object
-
#initialize(x, y, size, details) ⇒ Tile
constructor
A new instance of Tile.
Constructor Details
#initialize(x, y, size, details) ⇒ Tile
Returns a new instance of Tile.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/gridmap.rb', line 135 def initialize(x, y, size, details) @x, @y, @size, @details = x, y, size, details @offset_x = details[:offset_x] if details[:offset_x] @offset_y = details[:offset_y] if details[:offset_y] @z = details[:z] if details[:z] @angle = details[:angle] if details[:angle] @offset_x ||= 0 @offset_y ||= 0 @z ||= 0 @angle ||= 0 @centre_point = [@x * @size + @size / 2, @y * @size + @size / 2] end |
Instance Attribute Details
#angle ⇒ Object
Returns the value of attribute angle.
134 135 136 |
# File 'lib/gridmap.rb', line 134 def angle @angle end |
#centre_point ⇒ Object
Returns the value of attribute centre_point.
134 135 136 |
# File 'lib/gridmap.rb', line 134 def centre_point @centre_point end |
#connections ⇒ Object
Returns the value of attribute connections.
134 135 136 |
# File 'lib/gridmap.rb', line 134 def connections @connections end |
#details ⇒ Object
Returns the value of attribute details.
134 135 136 |
# File 'lib/gridmap.rb', line 134 def details @details end |
#image ⇒ Object
Returns the value of attribute image.
134 135 136 |
# File 'lib/gridmap.rb', line 134 def image @image end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
133 134 135 |
# File 'lib/gridmap.rb', line 133 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
133 134 135 |
# File 'lib/gridmap.rb', line 133 def y @y end |
#z ⇒ Object
Returns the value of attribute z.
134 135 136 |
# File 'lib/gridmap.rb', line 134 def z @z end |
Instance Method Details
#draw ⇒ Object
151 152 153 154 155 156 157 |
# File 'lib/gridmap.rb', line 151 def draw if @details[:connected] || @details[:orientated] draw_rot else @image.draw @x * @size + @offset_x, @y * @size + @offset_y, @z end end |
#draw_rot ⇒ Object
159 160 161 |
# File 'lib/gridmap.rb', line 159 def draw_rot @image.draw_rot @centre_point[0], @centre_point[1], @z, @angle end |