Added animated item
This commit is contained in:
parent
0ef1a15efc
commit
35d35da83d
2 changed files with 16 additions and 1 deletions
|
@ -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'))
|
||||||
|
|
15
src/items/animateditem.coffee
Normal file
15
src/items/animateditem.coffee
Normal 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
|
Loading…
Reference in a new issue