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
readonly
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.
-
#pixel_x ⇒ Object
readonly
Returns the value of attribute pixel_x.
-
#pixel_y ⇒ Object
readonly
Returns the value of attribute pixel_y.
-
#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.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/gridmap.rb', line 171 def initialize(x, y, size, details) @x, @y, @size, @details = x, y, size, details @pixel_x = @x * size @pixel_y = @y * size @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.
170 171 172 |
# File 'lib/gridmap.rb', line 170 def angle @angle end |
#centre_point ⇒ Object (readonly)
Returns the value of attribute centre_point.
169 170 171 |
# File 'lib/gridmap.rb', line 169 def centre_point @centre_point end |
#connections ⇒ Object
Returns the value of attribute connections.
170 171 172 |
# File 'lib/gridmap.rb', line 170 def connections @connections end |
#details ⇒ Object
Returns the value of attribute details.
170 171 172 |
# File 'lib/gridmap.rb', line 170 def details @details end |
#image ⇒ Object
Returns the value of attribute image.
170 171 172 |
# File 'lib/gridmap.rb', line 170 def image @image end |
#pixel_x ⇒ Object (readonly)
Returns the value of attribute pixel_x.
169 170 171 |
# File 'lib/gridmap.rb', line 169 def pixel_x @pixel_x end |
#pixel_y ⇒ Object (readonly)
Returns the value of attribute pixel_y.
169 170 171 |
# File 'lib/gridmap.rb', line 169 def pixel_y @pixel_y end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
169 170 171 |
# File 'lib/gridmap.rb', line 169 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
169 170 171 |
# File 'lib/gridmap.rb', line 169 def y @y end |
#z ⇒ Object
Returns the value of attribute z.
170 171 172 |
# File 'lib/gridmap.rb', line 170 def z @z end |
Instance Method Details
#draw ⇒ Object
189 190 191 192 193 194 195 |
# File 'lib/gridmap.rb', line 189 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
197 198 199 |
# File 'lib/gridmap.rb', line 197 def draw_rot @image.draw_rot @centre_point[0], @centre_point[1], @z, @angle end |