Skip to content

Commit

Permalink
add animation turning player to zombie
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Urbas committed Nov 30, 2013
1 parent 58a621f commit 4852f86
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
23 changes: 16 additions & 7 deletions app/scripts/game.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions app/scripts/game/sprites/characters/player.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ Q.Sprite.extend "Player",
return

# zombie mode!
Game.infoLabel.zombieModeOn()

zombiePlayer = @stage.insert new Q.ZombiePlayer
x: do =>
if @p.y > Game.map.p.h
Expand All @@ -183,6 +181,7 @@ Q.Sprite.extend "Player",
return @p.y

Game.setCameraTo(@stage, zombiePlayer)
zombiePlayer.p.direction = @p.direction

@destroy()

Expand Down
21 changes: 15 additions & 6 deletions app/scripts/game/sprites/characters/zombie_player.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ Q.animations "zombiePlayer",
frames: [3]
rate: 1
intro:
frames: [0, 1, 2]
rate: 0.7
frames: [0, 1, 0, 1, 0, 1]
rate: 0.8
next: "stand"
trigger: "ready"

# main object and logic
Q.Sprite.extend "ZombiePlayer",
Expand All @@ -30,13 +31,24 @@ Q.Sprite.extend "ZombiePlayer",
type: Game.SPRITE_ZOMBIE_PLAYER
collisionMask: Game.SPRITE_TILES | Game.SPRITE_HUMAN

@add("2d, platformerControls, animation")
@add("2d, animation")

@p.jumpSpeed = -500
@p.speed = 140
@p.savedPosition.x = @p.x
@p.savedPosition.y = @p.y
@p.playerDirection = @p.direction

Game.infoLabel.zombieModeOn()
@play "intro", 10

# events
@on "player.outOfMap", @, "die"
@on "ready", @, "enableZombieMode"

enableZombieMode: ->
@add "platformerControls"
@p.direction = @p.playerDirection
Game.infoLabel.zombieModeOnNext()
Game.currentLevelData.zombieModeFound = true
Game.playerAvatar.changeToZombie()
Expand All @@ -47,9 +59,6 @@ Q.Sprite.extend "ZombiePlayer",
Q.AudioManager.add Game.audio.zombieMode,
loop: true

# events
@on "player.outOfMap", @, "die"

step: (dt) ->
if @p.direction == "left"
@p.flip = "x"
Expand Down

0 comments on commit 4852f86

Please sign in to comment.