Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ node_js:
- "0.8"
- "0.10"

branches:
except:
- coffeescript

deploy:
provider: openshift
user: "aa1ronham@gmail.com"
Expand Down
15 changes: 15 additions & 0 deletions Cakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{exec} = require 'child_process'
COFFEE = 'coffee --compile'
COFFE_MAP = '#{COFFEE} --map'

task 'build', 'Build client and server code', ->
invoke 'build:client'
invoke 'build:server'

task 'build:client', 'Build client code only', ->
exec "#{COFFEE} client/js/", (err, stdout, stderr) ->
throw err if err

task 'build:server', 'Build server code only', ->
exec "#{COFFEE} server/js/", (err, stdout, stderr) ->
throw err if err
44 changes: 44 additions & 0 deletions client/js/animation.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
define ->
class Animation
constructor: (@name, @length, @row, @width, @height) ->
@reset()

tick: ->
i = @currentFrame.index

if i < @length - 1 then i += 1 else i = 0

if @count > 0 and i is 0
@count -= 1
if @count is 0
@currentFrame.index = 0
@endcount_callback()
return

@currentFrame.x = @width * i
@currentFrame.y = @height * @row
@currentFrame.index = i

setSpeed: (@speed) ->

setCount: (@count, @endcount_callback) ->

isTimeToAnimate: (time) ->
(time - @lastTime) > @speed

update: (time) ->
if @lastTime is 0 and @name[..3] is "atk"
@lastTime = time

if @isTimeToAnimate time
@lastTime = time
@tick()
true
else
false

reset: ->
@lastTime = 0
@currentFrame = { index: 0, x: 0, y: @row * @height }

Animation
Loading