Skip to content

Commit

Permalink
Health
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Applegate committed Dec 1, 2012
1 parent 3853821 commit 0520705
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions public/coffee/models/Character.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ define ['cs!models/DynamicEntity', 'image!/img/character.png'], (DynamicEntity,
@unlockCharacter()
@canvas.trigger 'attack.soundOff'
return
if @health? and not @actionLock then @health = @health + target.length
@lockCharacter()
target[0].$wrapper?.setAction 'disintegrate'

Expand All @@ -154,6 +155,7 @@ define ['cs!models/DynamicEntity', 'image!/img/character.png'], (DynamicEntity,
@unlockCharacter()
@canvas.trigger 'attack.soundOff'
return
if @health? and not @actionLock then @health = @health + target.length
@lockCharacter()
target[0].$wrapper.setAction 'disintegrate'

Expand All @@ -177,6 +179,8 @@ define ['cs!models/DynamicEntity', 'image!/img/character.png'], (DynamicEntity,
if @frame > 10
@createClone()
@unlockCharacter()
if @health? then @health = @health - 1
console.log @health
@setAction @previousAction

onImpact: =>
Expand Down
2 changes: 2 additions & 0 deletions public/coffee/models/PlayableCharacter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ define ['cs!models/Character', 'cs!models/CloneCharacter'], (Character, CloneCha
class PlayableCharacter extends Character

planted: false
health: 5

constructor: (@world, @overrides = {}) ->
@overrides.name = 'player'
Expand Down Expand Up @@ -39,6 +40,7 @@ define ['cs!models/Character', 'cs!models/CloneCharacter'], (Character, CloneCha
# Clone Action
if e.keyCode is 67
if @actionLock then return
return unless @health > 1
@setAction 'clone'
@canvas.trigger 'clone.sound'
return false
Expand Down

0 comments on commit 0520705

Please sign in to comment.