Fixed bugs with camera bobbing with bobbing units and gold views showing up when empty.

This commit is contained in:
Nick Winter 2014-06-23 10:36:36 -07:00
parent 27774cdf0f
commit 815ef88e78
4 changed files with 14 additions and 4 deletions

View file

@ -288,10 +288,13 @@ module.exports = class Camera extends CocoClass
boundTarget: (pos, zoom) ->
# Given an {x, y} in Surface coordinates, return one that will keep our viewport on the Surface.
return pos unless @bounds
y = pos.y
if thang = pos.sprite?.thang
y = @worldToSurface(x: thang.pos.x, y: thang.pos.y).y # ignore z
marginX = (@canvasWidth / zoom / 2)
marginY = (@canvasHeight / zoom / 2)
x = Math.min(Math.max(marginX + @bounds.x, pos.x + @offset.x), @bounds.x + @bounds.width - marginX)
y = Math.min(Math.max(marginY + @bounds.y, pos.y + @offset.y), @bounds.y + @bounds.height - marginY)
y = Math.min(Math.max(marginY + @bounds.y, y + @offset.y), @bounds.y + @bounds.height - marginY)
{x: x, y: y}
updateViewports: (target) ->

View file

@ -22,7 +22,11 @@ block content
p
strong Tournament ended!
a(href="#winners") Behold the winners
| . Thanks for playing!
| . Thanks for playing! You can
strong still play
| Greed and all of our other
a(href="/play/ladder") multiplayer arenas
| .
p
| Want to commiserate? Head over to
a(href="http://discourse.codecombat.com/") the forum

View file

@ -22,6 +22,7 @@ adminContacts = [
{id: "5162fab9c92b4c751e000274", name: "Scott"}
{id: "51eb2714fa058cb20d0006ef", name: "Michael"}
{id: "51538fdb812dd9af02000001", name: "George"}
{id: "52a57252a89409700d0000d9", name: "Ignore"}
]
module.exports = class ProfileView extends View

View file

@ -14,9 +14,9 @@ module.exports = class GoldView extends View
super options
@teamGold = {}
@teamGoldEarned = {}
@shownOnce = false
onGoldChanged: (e) ->
@$el.show()
return if @teamGold[e.team] is e.gold and @teamGoldEarned[e.team] is e.goldEarned
@teamGold[e.team] = e.gold
@teamGoldEarned[e.team] = e.goldEarned
@ -30,9 +30,11 @@ module.exports = class GoldView extends View
text += " (#{e.goldEarned})"
goldEl.text text
@updateTitle()
@$el.show()
@shownOnce = true
updateTitle: ->
@$el.attr 'title', ("Team '#{team}' has #{gold} now of #{@teamGoldEarned[team]} gold earned." for team, gold of @teamGold).join ' '
onSetLetterbox: (e) ->
@$el.toggle not e.on
@$el.toggle not e.on if @shownOnce