Messing with marks.

This commit is contained in:
Nick Winter 2014-06-24 15:45:27 -07:00
parent e3a87156a2
commit 580d002a98
4 changed files with 41 additions and 23 deletions

View file

@ -405,7 +405,7 @@ module.exports = class Simulator extends CocoClass
executionLimit: 1 * 1000 * 1000
language: codeLanguage
if methodName is 'hear' then aetherOptions.functionParameters = ['speaker', 'message', 'data']
if methodName is 'makeBid' then aetherOptions.functionParameters = ['blockNumber']
if methodName is 'makeBid' then aetherOptions.functionParameters = ['tileGroupNumber']
if methodName is "findCentroids" then aetherOptions.functionParameters = ["centroids"]
#console.log "creating aether with options", aetherOptions
return new Aether aetherOptions

View file

@ -67,28 +67,41 @@ module.exports = class Mark extends CocoClass
@mark.mouseChildren = false
# Confusingly make some semi-random colors that'll be consistent based on the drawsBoundsIndex
index = @sprite.thang.drawsBoundsIndex
colors = (128 + Math.floor(('0.'+Math.sin(3 * index + i).toString().substr(6)) * 128) for i in [1 ... 4])
@drawsBoundsIndex = @sprite.thang.drawsBoundsIndex
colors = (128 + Math.floor(('0.'+Math.sin(3 * @drawsBoundsIndex + i).toString().substr(6)) * 128) for i in [1 ... 4])
color = "rgba(#{colors[0]}, #{colors[1]}, #{colors[2]}, 0.5)"
shape = new createjs.Shape()
shape.graphics.setStrokeStyle 5
shape.graphics.beginStroke color
shape.graphics.beginFill color.replace('0.5', '0.25')
[w, h] = [@sprite.thang.width * Camera.PPM, @sprite.thang.height * Camera.PPM * @camera.y2x]
if @sprite.thang.shape in ["ellipsoid", "disc"]
shape.drawEllipse 0, 0, w, h
if @sprite.thang.drawsBoundsStyle is 'border-text'
shape = new createjs.Shape()
shape.graphics.setStrokeStyle 5
shape.graphics.beginStroke color
shape.graphics.beginFill color.replace('0.5', '0.25')
if @sprite.thang.shape in ["ellipsoid", "disc"]
shape.drawEllipse 0, 0, w, h
else
shape.graphics.drawRect -w / 2, -h / 2, w, h
shape.graphics.endStroke()
shape.graphics.endFill()
@mark.addChild shape
if @sprite.thang.drawsBoundsStyle is 'border-text'
text = new createjs.Text "" + @drawsBoundsIndex, "20px Arial", color.replace('0.5', '1')
text.regX = text.getMeasuredWidth() / 2
text.regY = text.getMeasuredHeight() / 2
text.shadow = new createjs.Shadow("#000000", 1, 1, 0)
@mark.addChild text
else if @sprite.thang.drawsBoundsStyle is 'corner-text'
return if @sprite.thang.world.age is 0
#letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[@drawsBoundsIndex % 26]
letter = @sprite.thang.drawsBoundsIndex
text = new createjs.Text letter, "14px Arial", "#333333" # color.replace('0.5', '1')
text.x = -w / 2 + 2
text.y = -h / 2 + 2
@mark.addChild text
else
shape.graphics.drawRect -w / 2, -h / 2, w, h
shape.graphics.endStroke()
shape.graphics.endFill()
console.warn @sprite.thang.id, "didn't know how to draw bounds style:", @sprite.thang.drawsBoundsStyle
text = new createjs.Text "" + index, "20px Arial", color.replace('0.5', '1')
text.regX = text.getMeasuredWidth() / 2
text.regY = text.getMeasuredHeight() / 2
text.shadow = new createjs.Shadow("#000000", 1, 1, 0)
@mark.addChild shape, text
if w > 0 and h > 0
@mark.cache -w / 2, -h / 2, w, h, 2
@lastWidth = @sprite.thang.width
@ -236,7 +249,7 @@ module.exports = class Mark extends CocoClass
if @name is 'shadow'
worldZ = @sprite.thang.pos.z - @sprite.thang.depth / 2 + @sprite.getBobOffset()
@mark.alpha = @alpha * 0.451 / Math.sqrt(worldZ / 2 + 1)
else
else if @name isnt "bounds"
@mark.alpha = @alpha
updateRotation: ->
@ -244,7 +257,7 @@ module.exports = class Mark extends CocoClass
@mark.rotation = @sprite.thang.rotation * 180 / Math.PI
updateScale: ->
if @name is 'bounds' and (@sprite.thang.width isnt @lastWidth or @sprite.thang.height isnt @lastHeight)
if @name is 'bounds' and ((@sprite.thang.width isnt @lastWidth or @sprite.thang.height isnt @lastHeight) or (@sprite.thang.drawsBoundsIndex isnt @drawsBoundsIndex))
oldMark = @mark
@buildBounds()
oldMark.parent.addChild @mark
@ -254,6 +267,11 @@ module.exports = class Mark extends CocoClass
if @markSprite?
@markSprite.scaleFactor = 1.2
@markSprite.updateScale()
if @name is 'shadow' and thang = @sprite.thang
@mark.scaleX = thang.scaleFactor ? thang.scaleFactorX ? 1
@mark.scaleY = thang.scaleFactor ? thang.scaleFactorY ? 1
return unless @name in ["selection", "target", "repair", "highlight"]
# scale these marks to 10m (100px). Adjust based on sprite size.

View file

@ -92,7 +92,7 @@ module.exports = class LadderSubmissionView extends CocoView
includeFlow: false
executionLimit: 1 * 1000 * 1000
if spellID is "hear" then aetherOptions.functionParameters = ["speaker","message","data"]
if spellID is "makeBid" then aetherOptions.functionParameters = ["blockNumber"]
if spellID is "makeBid" then aetherOptions.functionParameters = ["tileGroupNumber"]
if spellID is "findCentroids" then aetherOptions.functionParameters = ["centroids"]
aether = new Aether aetherOptions

View file

@ -41,7 +41,7 @@ transpileLevelSession = (sessionID, cb) ->
includeFlow: false
executionLimit: 1 * 1000 * 1000
if spellID is "hear" then aetherOptions.functionParameters = ["speaker","message","data"]
if spellID is "makeBid" then aetherOptions.functionParameters = ["blockNumber"]
if spellID is "makeBid" then aetherOptions.functionParameters = ["tileGroupNumber"]
if spellID is "findCentroids" then aetherOptions.functionParameters = ["centroids"]
aether = new Aether aetherOptions