Added animated item

This commit is contained in:
Ruben Müller 2014-12-07 13:48:12 +01:00
parent 0ef1a15efc
commit 35d35da83d
2 changed files with 16 additions and 1 deletions

View file

@ -21,7 +21,7 @@ gulp.task('server', function() {
}); });
gulp.task('compile', function() { gulp.task('compile', function() {
return gulp.src(['src/entities/*.coffee', 'src/tiles/*.coffee', 'src/tools.coffee', 'src/app.coffee', 'src/game.coffee', 'src/hud.coffee']) return gulp.src(['src/entities/*.coffee', 'src/items/*.coffee', , 'src/tiles/*.coffee', 'src/tools.coffee', 'src/app.coffee', 'src/game.coffee', 'src/hud.coffee'])
.pipe(sourcemaps.init()) .pipe(sourcemaps.init())
.pipe(coffee({bare: true})) .pipe(coffee({bare: true}))
.pipe(concat('app.js')) .pipe(concat('app.js'))

View file

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