summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Bini <michele.bini@gmail.com>2015-10-30 01:17:24 (GMT)
committerMichele Bini <michele.bini@gmail.com>2015-10-30 01:17:24 (GMT)
commit12f831083a56505b2cb32fe8cd825bce172c13cd (patch)
tree9036358ad11291f3b4b683542579cb17caeb9043
parent6b299dee4113166a64ed84453cd2a0d756ea9b9f (diff)
completed!!!
-rw-r--r--game.html.coffee106
1 files changed, 57 insertions, 49 deletions
diff --git a/game.html.coffee b/game.html.coffee
index 9701a25..b72aa51 100644
--- a/game.html.coffee
+++ b/game.html.coffee
@@ -75,7 +75,6 @@ genPage = ->
@div style:"text-align:right", id:"fps"
gameObjects = null
@script type:"text/javascript", "gameObjects=#{JSON.stringify(gameObjects)};"
- @script type:"text/javascript", "__hasProp = {}.hasOwnProperty; __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };"
@jsFile "jaws/jaws-min.js"
# @jsFile "jaws-assets-named.js"
@jsFile "lib/Evolving/evolving.js"
@@ -188,53 +187,57 @@ genPage = ->
# @px = px | 0
# @py = py | 0
@
- @Bubble = @Sprite
- @HappyBubble = class extends @Bubble
- image: happybubble0
- constructor: ->
+ @brew 'HappyBubble', @Sprite, ->
+ @image = happybubble0
+ @setConstructor ->
@lr = 4
@tb = 4
- super()
- draw: ->
+ @Sprite()
+ return
+ @draw = ->
@py--
- super()
- oxygen: 10
- score: 5
- bumpedInto: (o, qd, dx, dy)@>
+ @drawSprite()
+ @oxygen = 10
+ @score = 5
+ @bumpedInto = (o, qd, dx, dy)@>
return if @dead
# if dx * dx * 2 > qd
@dead = true
- @GrumpyBubble = class extends @Bubble
- image: grumpybubble0
- constructor: ->
+ @
+ @brew 'GrumpyBubble', @Sprite, ->
+ @image = grumpybubble0
+ @setConstructor ->
@lr = 7
@tb = 7
@cr = 8
@life = 60
- super()
- draw: (collisions, game)->
+ @Sprite()
+ return
+ @draw = (collisions, game)->
if game?.slowedBubbles
@py -= 2
else
@py -= 3
- super()
- bumpedInto: (o, qd, dx, dy)@>
+ @drawSprite()
+ @bumpedInto = (o, qd, dx, dy)@>
return if @dead
# if dx * dx * 2 > qd
# @dead = true
ovy = o.vy
o.py -= 3 + (ovy > 0 then @life -= ovy; ovy * 2 else 0)
@dead = true unless @life > 0
- @EvilBubble = class extends @Bubble
- image: evilbubble0
- constructor: ->
+ @
+ @brew 'EvilBubble', @Sprite, ->
+ @image = evilbubble0
+ @setConstructor ->
@lr = 15
@tb = 15
@cr = 8
@vy_ = -7
@life = 2200
- super()
- draw: (collisions, game)->
+ @Sprite()
+ return
+ @draw = (collisions, game)->
l = 0
if game.slowedBubbles
@py -= 3
@@ -248,8 +251,8 @@ genPage = ->
l = 2200 - l if l > 1100
l /= 55
@vy_ = - 8 - l
- super()
- bumpedInto: (o, qd, dx, dy)@>
+ @drawSprite()
+ @bumpedInto = (o, qd, dx, dy)@>
return if @dead
# if dx * dx * 2 > qd
# @dead = true
@@ -260,22 +263,23 @@ genPage = ->
o.px = @px
o.py = @py + @vy_
@dead = true unless @life > 0
+ @
@slowBubbles = @>
return if @slowedBubbles
@slowedBubbles = true
@quitSlowBubbles = @>
return unless @slowedBubbles
@slowedBubbles = false
- @Stilla = class extends @Bubble
- image: stilla0
- Bubble: @Bubble
- constructor: ->
+ @brew 'Stilla', @Sprite, ->
+ @image = stilla0
+ @setConstructor ->
@lr = 16
@tb = 20
@patience = 490
- super()
+ @Sprite()
+ return
# Math: Math
- draw: (collisions, game)->
+ @draw = (collisions, game)->
{ px, py, lr } = @
(spin = @spin) then
d = @@pow(px * px + py * py, 0.42)
@@ -342,10 +346,11 @@ genPage = ->
else
game.quitSlowBubbles()
@lr = -lr if px * lr > 0
- super()
- goodnight: (game)@> game.quitSlowBubbles()
- bumpedInto: (o)@>
+ @drawSprite()
+ @goodnight = (game)@> game.quitSlowBubbles()
+ @bumpedInto = (o)@>
o.dead = true
+ @
@brew 'Vaquita', @Sprite, ->
@Oxygenation = @Basic::evolve ->
@oxygen = 0.7
@@ -366,7 +371,7 @@ genPage = ->
@oxygen = new @Oxygenation
@Sprite()
return
- @draw = ->
+ @method 'draw', ->
@oxygen.consume()
if @vx < 0
@lr = - 18
@@ -375,13 +380,14 @@ genPage = ->
@drawSprite()
@bumpedInto = (x)@> @oxygen.addFrom(x)
@
- @AiVaquita = class extends @Vaquita
- constructor: ->
+ @brew 'AiVaquita', @Vaquita, ->
+ @setConstructor ->
@image = pixyvaquita
@time = 0
- super()
- beat_lr: 0
- draw: ->
+ @Vaquita()
+ return
+ @beat_lr = 0
+ @draw = ->
vx = @vx + Math.floor(@@random()*5) - 2
vy = @vy + Math.floor(@@random()*3) - 1
x = @px
@@ -398,19 +404,20 @@ genPage = ->
@image = pixyvaquita
else if vx * vx + vy * vy > 2
@image = @twist[ @beat_lr++ & 1 ]
- super()
- @Vilma = class extends @Vaquita
- constructor: (@game)->
+ @drawVaquita()
+ @
+ @brew 'Vilma', @Vaquita, ->
+ @setConstructor (@game)->
@image = pixyvaquita
@time = 0
- super()
+ @Vaquita()
@fpx = @px ? 0
@fpy = @py ? 0
@touch = @game.touchInput
@auto_to = 40
@score = 0
- beat_lr: 0
- move: ->
+ @beat_lr = 0
+ @move = ->
touch <. @
# { tx, ty } = touch
@@ -496,18 +503,19 @@ genPage = ->
vy *= 0.95
@px = round(@fpx += (@vx = vx))
@py = round(@fpy += (@vy = vy))
- draw: ->
+ @draw = ->
{ vx, vy } = @
if (@time++ % 3) is 0
if @image isnt pixyvaquita
@image = pixyvaquita
else if vx * vx + (vy * vy / 4) > 1
@image = @twist[@beat_lr++ & 1]
- super()
- bumpedInto: (x)@>
+ @drawVaquita()
+ @bumpedInto = (x)@>
@oxygen.addFrom(x)
score <. x
@score += score if score?
+ @
@addVaquita = ->
# n = v.cloneNode()
# n.setAttribute "opacity", "0.5"