Module: DXRuby::Tiled::FlippedTileObject

Defined in:
lib/dxruby_tiled/object.rb

Instance Method Summary collapse

Instance Method Details

#drawObject



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/dxruby_tiled/object.rb', line 229

def draw
  @start_time ||= DXRuby::Window::running_time
  tile = @tile.animate((DXRuby::Window::running_time - @start_time))
  self.image = tile.original_image
  sin = Math.sin(2 * Math::PI * self.angle / 360)
  cos = Math.cos(2 * Math::PI * self.angle / 360)
  cx = (self.image.width  * 0.5 + tile.offset_x) * self.scale_x.abs
  cy = (self.image.height * 0.5 - tile.offset_y) * self.scale_y.abs
  x = self.x + cx * cos + cy * sin
  y = self.y - cy * cos + cx * sin
  self.target.draw_ex(x, y, self.image,
    scale_x:  self.scale_x,
    scale_y:  self.scale_y,
    alpha:    self.alpha,
    blend:    self.blend,
    angle:    self.angle,
    shader:   self.shader,
    z:        self.z,
    offset_sync: true
  )
end