diff options
| author | Michele Bini <michele.bini@gmail.com> | 2015-10-29 18:12:30 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2015-10-29 18:12:30 (GMT) |
| commit | 3a19e01554e9d0c4e459a377d85084d9a22cc5f7 (patch) | |
| tree | 1ecc52bffee1e95cbe5877e9ac6650fa96408b15 | |
| parent | ccca071597026956f88531da079b0709e45da765 (diff) | |
continued...
| -rw-r--r-- | game.html.coffee | 75 |
1 files changed, 28 insertions, 47 deletions
diff --git a/game.html.coffee b/game.html.coffee index 617216a..bec392d 100644 --- a/game.html.coffee +++ b/game.html.coffee @@ -685,11 +685,10 @@ genPage = -> @ongoing = { } @ false then @ColorPlane = do=> - document: document init: @> color <. @ if color and typeof color is 'string' - e = @document.createElement "canvas" + e = @@document.createElement "canvas" e.width = @w e.height = @h ctx = e.getContext '2d' @@ -699,17 +698,14 @@ genPage = -> t.fillStyle = @color t.fillRect 0,0,1024,1024 # t.restore() - @GenericPlane = - document: document - init: @> - document <. @ - e = document.createElement "canvas" + @brew 'GenericPlane', @Basic, -> + @method 'init', @> + e = @@document.createElement "canvas" e.width = @w e.height = @h @ctx = e.getContext '2d' - + @ @ScaledImg = ScaledImg = - document: document zoom: 2 init: @> retroScaling = (c)-> @@ -721,30 +717,27 @@ genPage = -> { width, height } = @img @w = w = width * zoom @h = h = height * zoom - c0 = e = @document.createElement "canvas" + c0 = e = @@document.createElement "canvas" retroScaling(c0) e.width = w e.height = height ctx0 = e.getContext '2d' retroScaling(ctx0) ctx0.drawImage @img, 0, 0, width, height, 0, 0, w, height - @canvas = e = @document.createElement "canvas" + @canvas = e = @@document.createElement "canvas" e.width = w e.height = h ctx = e.getContext '2d' retroScaling(ctx) @ctx = ctx.drawImage c0, 0, 0, w, height, 0, 0, w, h - - @ParallaxPlane = - __proto__: @GenericPlane - ParallaxPlaneSuper: @GenericPlane - lower: null - x: 0 - y: 0 - fx: 0 - fy: 0 - logzoom: 2 - frame: (t,dx,dy)@> + @brew 'ParallaxPlane', @GenericPlane, -> + @lower = null + @x = 0 + @y = 0 + @fx = 0 + @fy = 0 + @logzoom = 2 + @frame = (t,dx,dy)@> { fx, fy, x, y, abslogzoom, w, h, ctx } = @ nfx = fx + dx nfy = fy + dy @@ -774,20 +767,18 @@ genPage = -> t.drawImage canvas, nx - w, ny t.drawImage canvas, nx, ny - h t.drawImage canvas, nx - w, ny - h - init: (options)@> + @method 'init', (options)@> @abslogzoom ?= @logzoom (l = @lower)? then l.logzoom? then l.abslogzoom ?= @logzoom + l.logzoom l.init(options) - @ParallaxPlaneSuper.init.call @, options - @BoundParallaxPlane = - __proto__: @ParallaxPlane - BoundParallaxPlaneProto: @ParallaxPlane - pmul: 1 - alert: alert - init: (options)@> + @initGenericPlane(options) + @ + @brew 'BoundParallaxPlane', @ParallaxPlane, -> + @pmul = 1 + @method 'init', (options)@> { screenw, screenh } = options - @BoundParallaxPlaneProto.init.call @ + @initParallaxPlane() { logzoom, abslogzoom, w, h, pmul } = @ @mx = ((w << abslogzoom) * pmul - screenw * 8) >> abslogzoom @my = ((h << abslogzoom) * pmul - screenh * 8) >> abslogzoom @@ -797,7 +788,7 @@ genPage = -> @fy = (@y = @my) << abslogzoom @fx = @fy = 0 @mfy = @my << abslogzoom - frame: (t, dx, dy)@> + @frame = (t, dx, dy)@> { fx, fy, x, y, abslogzoom, w, h, ctx } = @ nfx = fx - dx nfy = fy - dy @@ -828,10 +819,10 @@ genPage = -> # @mny = 100 t.drawImage canvas, -nx, -ny # t.drawImage canvas, 0, 0, w, h, -nx, -ny, w*pmul, h*pmul - + @ @SeaFloor = do=> - __proto__: @BoundParallaxPlane - SeaFloorProto: @BoundParallaxPlane + __proto__: @BoundParallaxPlane:: + SeaFloorProto: @BoundParallaxPlane:: # terror: CuteluTerror = # img: cuteluterror # zoom: 6 @@ -859,7 +850,6 @@ genPage = -> ctx.fillRect 0, 0, 1, h ctx.fillRect 0, h - 1, w, 1 ctx.fillRect w - 1, 0, 1, h - @SeamlessPlane = withRect: (rx,ry,rw,rh,cb)@> { w, h } = @ @@ -878,8 +868,7 @@ genPage = -> cb rx, 0, rw, ey - h, 0, h - ry else cb rx, ry, rw, rh, 0, 0 - __proto__: @ParallaxPlane - + __proto__: @ParallaxPlane:: @WaterPlane = do=> waterscapeSuper: waterscapeSuper = @SeamlessPlane __proto__: waterscapeSuper @@ -1033,17 +1022,9 @@ genPage = -> delete game.other.scoreBox @waves = intro: @> - - game: @> - - score: @> - - setup: @> - - # PinkWaveletPlane: PinkWaveletPlane = do-> # waterscapeSuper: waterscapeSuper = SeamlessPlane # __proto__: waterscapeSuper @@ -1184,7 +1165,7 @@ genPage = -> touchInput <. @ touchInput.game = @ - x = document.body + x = @@document.body x.addEventListener "touchmove", touchInput.handle('move'), true x.addEventListener "touchstart", touchInput.handle('start'), true tend = touchInput.handle 'end' |
