gradually increasing difficulty
This commit is contained in:
parent
8f687bbf80
commit
393e6f58b4
|
@ -36,10 +36,11 @@
|
||||||
|
|
||||||
(fn restart []
|
(fn restart []
|
||||||
(tbl.extend state
|
(tbl.extend state
|
||||||
{:bomber {:x 200}
|
{:bomber {:x 200 :bombs-left 0}
|
||||||
:bombs []
|
:bombs []
|
||||||
:bucket {:count 3}
|
:bucket {:count 3}
|
||||||
:level 1
|
:level 1
|
||||||
|
:state :waiting
|
||||||
:scene :ingame}))
|
:scene :ingame}))
|
||||||
|
|
||||||
(children:defmethod :bombs iter.reverse-ipairs)
|
(children:defmethod :bombs iter.reverse-ipairs)
|
||||||
|
@ -62,7 +63,8 @@
|
||||||
(set ctx.bomber.bombs-left 0)
|
(set ctx.bomber.bombs-left 0)
|
||||||
(cache.destroy :bucket count)
|
(cache.destroy :bucket count)
|
||||||
(destroy-all :bombs ctx)
|
(destroy-all :bombs ctx)
|
||||||
(set ctx.bombs [])))
|
(set ctx.bombs [])
|
||||||
|
(set ctx.state :waiting)))
|
||||||
|
|
||||||
(update:defmethod :bucket (fn [_ bucket]
|
(update:defmethod :bucket (fn [_ bucket]
|
||||||
(let [crank (playdate.getCrankPosition)
|
(let [crank (playdate.getCrankPosition)
|
||||||
|
@ -75,7 +77,7 @@
|
||||||
(let [image (make-image 20 30 #(gfx.fillRoundRect 0 0 20 30 6))]
|
(let [image (make-image 20 30 #(gfx.fillRoundRect 0 0 20 30 6))]
|
||||||
(defsprite :bomber #(with-image $1 image 0.5 0)))
|
(defsprite :bomber #(with-image $1 image 0.5 0)))
|
||||||
|
|
||||||
(fn bomberspeed [ctx] (* (+ ctx.level 4) 2))
|
(fn bomberspeed [ctx] (+ ctx.level 5))
|
||||||
(fn bombervelocity [ctx dx]
|
(fn bombervelocity [ctx dx]
|
||||||
(let [sign (if (< dx 0) -1 1)
|
(let [sign (if (< dx 0) -1 1)
|
||||||
speed (math.min (bomberspeed ctx) (math.abs dx))]
|
speed (math.min (bomberspeed ctx) (math.abs dx))]
|
||||||
|
@ -103,11 +105,17 @@
|
||||||
(when (<= bomber.bombframes 0)
|
(when (<= bomber.bombframes 0)
|
||||||
(drop-bomb ctx)))
|
(drop-bomb ctx)))
|
||||||
|
|
||||||
|
(when (and (= ctx.state :bombing) (= bomber.bombs-left 0) (= (length ctx.bombs) 0))
|
||||||
|
(set ctx.level (+ ctx.level 1))
|
||||||
|
(set ctx.state :waiting))
|
||||||
|
|
||||||
(doto (sprite :bomber) (: :moveTo bomber.x 5))
|
(doto (sprite :bomber) (: :moveTo bomber.x 5))
|
||||||
(when (playdate.buttonJustPressed :a)
|
(when (and (= ctx.state :waiting) (playdate.buttonJustPressed :a))
|
||||||
|
(set ctx.state :bombing)
|
||||||
(set bomber.bombs-left (bombcount ctx))
|
(set bomber.bombs-left (bombcount ctx))
|
||||||
(drop-bomb ctx))
|
(drop-bomb ctx))
|
||||||
(when (playdate.buttonJustPressed :b)
|
(when (playdate.buttonJustPressed :b)
|
||||||
|
(set ctx.level 1)
|
||||||
(set ctx.bucket.count 3))))
|
(set ctx.bucket.count 3))))
|
||||||
|
|
||||||
(gfx.sprite.setBackgroundDrawingCallback #(gfx.drawLine 0 33 screenw 33))
|
(gfx.sprite.setBackgroundDrawingCallback #(gfx.drawLine 0 33 screenw 33))
|
||||||
|
|
Loading…
Reference in a new issue