Class: Tile

Inherits:
Object
  • Object
show all
Defined in:
lib/gridmap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#angleObject

Returns the value of attribute angle.



134
135
136
# File 'lib/gridmap.rb', line 134

def angle
  @angle
end

#centre_pointObject

Returns the value of attribute centre_point.



134
135
136
# File 'lib/gridmap.rb', line 134

def centre_point
  @centre_point
end

#connectionsObject

Returns the value of attribute connections.



134
135
136
# File 'lib/gridmap.rb', line 134

def connections
  @connections
end

#detailsObject

Returns the value of attribute details.



134
135
136
# File 'lib/gridmap.rb', line 134

def details
  @details
end

#imageObject

Returns the value of attribute image.



134
135
136
# File 'lib/gridmap.rb', line 134

def image
  @image
end

#xObject (readonly)

Returns the value of attribute x.



133
134
135
# File 'lib/gridmap.rb', line 133

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



133
134
135
# File 'lib/gridmap.rb', line 133

def y
  @y
end

#zObject

Returns the value of attribute z.



134
135
136
# File 'lib/gridmap.rb', line 134

def z
  @z
end

Instance Method Details

#drawObject



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_rotObject



159
160
161
# File 'lib/gridmap.rb', line 159

def draw_rot
	@image.draw_rot @centre_point[0], @centre_point[1], @z, @angle
end