ld31-space-diggers/src/items/animateditem.coffee

16 lines
287 B
CoffeeScript

class AnimatedItem
constructor: (options) ->
{@maxFrames, @image, @speed} = options
@frame = 0
window.setInterval @changeAnimation, @speed
sprite: ->
[@frame*8, 0, 8, 8]
changeAnimation: =>
if @frame == @maxFrames
@frame = 0
else
@frame += 1