diff options
| author | Michele Bini <michele.bini@gmail.com> | 2015-10-30 01:02:11 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2015-10-30 01:02:11 (GMT) |
| commit | 6b299dee4113166a64ed84453cd2a0d756ea9b9f (patch) | |
| tree | 1cf4546074a294dd06a8d3a45b7c186d59d00551 | |
| parent | d18fd2e75228c94bcaee9e743e8f1d0cc604e6e5 (diff) | |
continued...
| -rw-r--r-- | game.html.coffee | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/game.html.coffee b/game.html.coffee index 372bb63..9701a25 100644 --- a/game.html.coffee +++ b/game.html.coffee @@ -130,6 +130,10 @@ genPage = -> @[name] = c = @evolve -> evolution.call(@,p) @process = (x)@> x.call(@) @spawn = (x)@> new @constructor().process(x) + @forge = (x)@> + c = -> + c.prototype = @ + new c().process(x) @ Basic::Basic = Basic Demo = Basic::evolve -> @@ -906,11 +910,11 @@ genPage = -> t.restore() @logzoom = 0 @ - @textRenderer = textRenderer = - glyphs: fontglyphs - charMap: {"0":{"w":5,"o":509},"1":{"w":3,"o":518},"2":{"w":4,"o":525},"3":{"w":4,"o":533},"4":{"w":4,"o":541},"5":{"w":4,"o":549},"6":{"w":4,"o":557},"7":{"w":3,"o":565},"8":{"w":4,"o":572},"9":{"w":4,"o":580}," ":{"w":2,"o":0},"a":{"w":4,"o":6},"b":{"w":4,"o":14},"c":{"w":4,"o":22},"d":{"w":4,"o":30},"e":{"w":4,"o":38},"f":{"w":2,"o":46},"g":{"w":4,"o":52},"h":{"w":4,"o":60},"i":{"w":2,"o":68},"j":{"w":2,"o":74},"k":{"w":4,"o":80},"l":{"w":2,"o":88},"m":{"w":6,"o":94},"n":{"w":4,"o":104},"o":{"w":4,"o":112},"p":{"w":4,"o":120},"q":{"w":4,"o":128},"r":{"w":3,"o":136},"s":{"w":3,"o":143},"t":{"w":3,"o":150},"u":{"w":4,"o":157},"v":{"w":4,"o":165},"w":{"w":5,"o":173},"x":{"w":3,"o":182},"y":{"w":4,"o":189},"z":{"w":3,"o":197},"ñ":{"w":4,"o":204},"ç":{"w":4,"o":212},"A":{"w":5,"o":220},"B":{"w":4,"o":229},"C":{"w":6,"o":237},"D":{"w":6,"o":247},"E":{"w":4,"o":257},"F":{"w":4,"o":265},"G":{"w":6,"o":273},"H":{"w":6,"o":283},"I":{"w":2,"o":293},"J":{"w":2,"o":299},"K":{"w":5,"o":305},"L":{"w":4,"o":314},"M":{"w":7,"o":322},"N":{"w":6,"o":333},"O":{"w":6,"o":343},"P":{"w":4,"o":353},"Q":{"w":6,"o":361},"R":{"w":5,"o":371},"S":{"w":4,"o":380},"T":{"w":5,"o":388},"U":{"w":6,"o":397},"V":{"w":5,"o":407},"W":{"w":7,"o":416},"X":{"w":5,"o":427},"Y":{"w":5,"o":436},"Z":{"w":5,"o":445},"!":{"w":2,"o":454},"?":{"w":3,"o":460},",":{"w":2,"o":467},".":{"w":2,"o":473},"@":{"w":6,"o":479},"/":{"w":4,"o":489},":":{"w":2,"o":497},";":{"w":2,"o":503},"á":{"w":4,"o":588},"é":{"w":4,"o":596},"í":{"w":2,"o":604},"ó":{"w":4,"o":610},"ú":{"w":4,"o":618},"à":{"w":4,"o":626},"è":{"w":4,"o":634},"ì":{"w":2,"o":642},"ò":{"w":4,"o":648},"ù":{"w":4,"o":656}} - lineHeight: 12 - fancyDrawText: (t, x, y)@> + @textRenderer = @Basic::forge -> + @glyphs = fontglyphs + @charMap = {"0":{"w":5,"o":509},"1":{"w":3,"o":518},"2":{"w":4,"o":525},"3":{"w":4,"o":533},"4":{"w":4,"o":541},"5":{"w":4,"o":549},"6":{"w":4,"o":557},"7":{"w":3,"o":565},"8":{"w":4,"o":572},"9":{"w":4,"o":580}," ":{"w":2,"o":0},"a":{"w":4,"o":6},"b":{"w":4,"o":14},"c":{"w":4,"o":22},"d":{"w":4,"o":30},"e":{"w":4,"o":38},"f":{"w":2,"o":46},"g":{"w":4,"o":52},"h":{"w":4,"o":60},"i":{"w":2,"o":68},"j":{"w":2,"o":74},"k":{"w":4,"o":80},"l":{"w":2,"o":88},"m":{"w":6,"o":94},"n":{"w":4,"o":104},"o":{"w":4,"o":112},"p":{"w":4,"o":120},"q":{"w":4,"o":128},"r":{"w":3,"o":136},"s":{"w":3,"o":143},"t":{"w":3,"o":150},"u":{"w":4,"o":157},"v":{"w":4,"o":165},"w":{"w":5,"o":173},"x":{"w":3,"o":182},"y":{"w":4,"o":189},"z":{"w":3,"o":197},"ñ":{"w":4,"o":204},"ç":{"w":4,"o":212},"A":{"w":5,"o":220},"B":{"w":4,"o":229},"C":{"w":6,"o":237},"D":{"w":6,"o":247},"E":{"w":4,"o":257},"F":{"w":4,"o":265},"G":{"w":6,"o":273},"H":{"w":6,"o":283},"I":{"w":2,"o":293},"J":{"w":2,"o":299},"K":{"w":5,"o":305},"L":{"w":4,"o":314},"M":{"w":7,"o":322},"N":{"w":6,"o":333},"O":{"w":6,"o":343},"P":{"w":4,"o":353},"Q":{"w":6,"o":361},"R":{"w":5,"o":371},"S":{"w":4,"o":380},"T":{"w":5,"o":388},"U":{"w":6,"o":397},"V":{"w":5,"o":407},"W":{"w":7,"o":416},"X":{"w":5,"o":427},"Y":{"w":5,"o":436},"Z":{"w":5,"o":445},"!":{"w":2,"o":454},"?":{"w":3,"o":460},",":{"w":2,"o":467},".":{"w":2,"o":473},"@":{"w":6,"o":479},"/":{"w":4,"o":489},":":{"w":2,"o":497},";":{"w":2,"o":503},"á":{"w":4,"o":588},"é":{"w":4,"o":596},"í":{"w":2,"o":604},"ó":{"w":4,"o":610},"ú":{"w":4,"o":618},"à":{"w":4,"o":626},"è":{"w":4,"o":634},"ì":{"w":2,"o":642},"ò":{"w":4,"o":648},"ù":{"w":4,"o":656}} + @lineHeight = 12 + @fancyDrawText = (t, x, y)@> { charMap, lineHeight, glyphs } = @ scale = 2 fancy_r <. @ @@ -929,7 +933,7 @@ genPage = -> @ctx.drawImage glyphs, o, 0, w + 4, lineHeight, x, (y + fancy) * scale, (w + 4) * scale, lineHeight * scale x += (w + 1) * scale fancy_r >. @ - drawText: (t, x, y)@> + @drawText = (t, x, y)@> { charMap, lineHeight, glyphs } = @ scale = 2 for c in t @@ -937,11 +941,12 @@ genPage = -> { w, o } = p # throw o @ctx.drawImage glyphs, o, 0, w + 4, lineHeight, x, y * scale, (w + 4) * scale, lineHeight * scale - x += (w + 1) * scale - @narrator = do=> - first: null - last: null - say: (t)@> + x += (w + 1) * scale + @ + @narrator = @textRenderer.forge -> + @first = null + @last = null + @say = (t)@> { last, game } = @ game.other.narrator = @ unless game.other.narrator? first = null @@ -952,7 +957,7 @@ genPage = -> first ?= last @last = last @first ?= first - draw: @> + @draw = @> { first, game } = @ unless first? delete game.other.narrator @@ -994,10 +999,10 @@ genPage = -> px = x + w + 1 last = first first = first.next - @first = first if x <= -w - __proto__: textRenderer + @first = first if x <= -w + @ @scoreBox = - textRenderer: textRenderer + textRenderer: @textRenderer score: 0 draw: @> { game, textRenderer } = @ |
