From c62cc69d15f40561d376ed2a4eef5593a8e86c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20M=C3=BCller?= Date: Sun, 7 Dec 2014 14:45:13 +0100 Subject: [PATCH] Added animations --- src/entities/base.coffee | 14 ++++++++++++-- src/entities/miner.coffee | 12 +++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/entities/base.coffee b/src/entities/base.coffee index db3dc3c..46d36fe 100644 --- a/src/entities/base.coffee +++ b/src/entities/base.coffee @@ -1,12 +1,22 @@ class Base + constructor: -> + @frame = 0 + + window.setInterval @changeAnimation, 500 + tick: (tile)-> sprite: -> - [0, 0, 8, 8] + [@frame*8, 0, 8, 8] isMoveable: -> false + changeAnimation: => + if @frame == 3 + @frame = 0 + else + @frame += 1 + spaceProvided: 50 isDockable: true - diff --git a/src/entities/miner.coffee b/src/entities/miner.coffee index 82ea4e3..99cf553 100644 --- a/src/entities/miner.coffee +++ b/src/entities/miner.coffee @@ -1,12 +1,22 @@ class Miner + constructor: -> + @frame = 0 + window.setInterval @changeAnimation, 500 + tick: (tile)-> tile.click "left" sprite: -> - [0, 16, 8, 8] + [@frame*8, 16, 8, 8] isMoveable: -> true + changeAnimation: => + if @frame == 1 + @frame = 0 + else + @frame += 1 + spaceProvided: 5 isDockable: false