From 35d35da83dc7d2e0e206bcb7064ff0ea7da7f5be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20M=C3=BCller?= Date: Sun, 7 Dec 2014 13:48:12 +0100 Subject: [PATCH] Added animated item --- gulpfile.js | 2 +- src/items/animateditem.coffee | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/items/animateditem.coffee diff --git a/gulpfile.js b/gulpfile.js index ce41c01..092f154 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -21,7 +21,7 @@ gulp.task('server', 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(coffee({bare: true})) .pipe(concat('app.js')) diff --git a/src/items/animateditem.coffee b/src/items/animateditem.coffee new file mode 100644 index 0000000..f1cb5e3 --- /dev/null +++ b/src/items/animateditem.coffee @@ -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