Merge branch 'thanish-move-wizard' of git://github.com/mnmtanish/codecombat into mnmtanish-thanish-move-wizard

This commit is contained in:
Nick Winter 2014-03-01 08:57:02 -08:00
commit bb53942c2c
3 changed files with 35 additions and 5 deletions

View file

@ -22,6 +22,7 @@ module.exports = class LevelBus extends Bus
'level-show-victory': 'onVictory'
'tome:spell-changed': 'onSpellChanged'
'tome:spell-created': 'onSpellCreated'
'self-wizard:move': 'moveWizard'
constructor: ->
super(arguments...)
@ -240,3 +241,12 @@ module.exports = class LevelBus extends Bus
destroy: ->
@session.off 'change:multiplayer', @onMultiplayerChanged, @
super()
moveWizard : (x, y) =>
wizardSprite = @getSelfWizard()
position = wizardSprite.getCurrentPosition()
position.x += x
position.y += y
wizardSprite.setTarget(position,1000)
wizardSprite.updatePosition()
Backbone.Mediator.publish 'camera-zoom-to', position

View file

@ -42,6 +42,7 @@ module.exports = class Camera extends CocoClass
'level:restarted': 'onLevelRestarted'
'sprite:mouse-down': 'onMouseDown'
'sprite:dragged': 'onMouseDragged'
'camera-zoom-to': 'onZoomTo'
# TODO: Fix tests to not use mainLayer
constructor: (@canvasWidth, @canvasHeight, angle=Math.asin(0.75), hFOV=d2r(30)) ->
@ -308,3 +309,6 @@ module.exports = class Camera extends CocoClass
createjs.Tween.removeTweens @
@finishTween = null
super()
onZoomTo: (pos) ->
@zoomTo(@worldToSurface(pos), @zoom)

View file

@ -36,6 +36,10 @@ module.exports = class PlaybackView extends View
'⌘+p, p, ctrl+p': 'onTogglePlay'
'⌘+[, ctrl+[': 'onScrubBack'
'⌘+], ctrl+]': 'onScrubForward'
'w, up': 'onMoveUpKey'
's, down': 'onMoveDownKey'
'a, left': 'onMoveLeftKey'
'd, right': 'onMoveRightKey'
constructor: ->
super(arguments...)
@ -215,3 +219,15 @@ module.exports = class PlaybackView extends View
$(window).off('resize', @onWindowResize)
@onWindowResize = null
super()
onMoveUpKey: ->
Backbone.Mediator.publish 'self-wizard:move', 0, 10
onMoveDownKey: ->
Backbone.Mediator.publish 'self-wizard:move', 0, -10
onMoveLeftKey: ->
Backbone.Mediator.publish 'self-wizard:move', -10, 0
onMoveRightKey: ->
Backbone.Mediator.publish 'self-wizard:move', 10, 0