Skip to content

Commit

Permalink
Final jam version
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandevai committed Apr 20, 2020
1 parent 2e43560 commit 430fc77
Show file tree
Hide file tree
Showing 2 changed files with 175 additions and 9 deletions.
88 changes: 87 additions & 1 deletion source/data.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,50 @@
;; 157:0500505555555555555555550555555505555555555555555555555505555555
;; 158:5555555555555555055555555555555555555555055555555555555505550055
;; 159:5555555055555555555555555555555055555550555555555555555555050050
;; 161:0000000000000000000000000000000000000000000000000000000000666666
;; 162:0000000000000000006600000ff660000ff06600000066600000066066600660
;; 164:00000000000000000000000000000000000000060000066600006eee000aaeae
;; 165:000000000000000000000000000000006666660066666666aeee6eeeaeeeaeea
;; 166:00000000000000000000000000000000000000ff000000ff6000000060000000
;; 167:0000000000000000000000000000000000000000000000006000000060000000
;; 168:00000000000000000000000000000000000000060000066600006eee000aaeae
;; 169:000000000000000000000000000000006666666066666666aeee6eeeaeeeaeea
;; 170:000000000000000000000000000000000000000000000000600000006000ff00
;; 176:0000000000000006000000660000a666000a66aa000a66a600a06aee000006e0
;; 177:666666666666666666666666a6666666a666666666aa6666eaa666a6aeee6a66
;; 178:6666666066666660666666666666166666111666666666666666666666666666
;; 179:0000000000000000000000006000000060006600606666006666660066666600
;; 180:000aeeae00a0eeae0aa0eeee0000aeee000aaeee00a00eee00000aee000000e6
;; 181:eaeeaeeaeaeeaeeaeaeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
;; 182:66000000e6000000e6600000e6600000ea660000eae66666aee66600eee66600
;; 183:0600000006000000060000000600000060000000000000000000000000000000
;; 184:000aeeae00a0eeae0aa0eeee0000aeee000aaeee00a00eee00000aee000000e6
;; 185:eaeeaeeaeaeeaeeaeaeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
;; 186:6600ff00e6000060e6600006e6600000ea660000eae66666aee66600eee66600
;; 187:0000000000000000000000006000000060000000000000000000000000000000
;; 192:000000000000000000000000000000000000006000a060a600a666a600a666aa
;; 193:eeeeea660eeeeae60eeeeeee0eeeeeee0eeeeeee0eeeeeeeeeeaeeeeeeeaeeee
;; 194:aa666666a6666666a6a66666e6a66666ee666666ee666666ee666666a66a6666
;; 195:6666660066666600666666006666660066666600600066000000060000000000
;; 196:000000ee000000ee000006ee000ae6ee0aeaeeee0aee6eee0aee6eea0aeaeeea
;; 197:eee66eeeeee66eeeeeeeeeeeeeeeeeeeeeeeeaeeeeeeaaeeeeeeaeeeeeaeaee6
;; 198:eee66600eee66660aee66666aee66666aea66666a6666666a666666666666666
;; 199:0060000006600000666000006660000066600000666000006660000066600000
;; 200:000000ee000000ee000006ee000ae6ee0aeaeeee0aee6eee0aee6eea0aeaeeea
;; 201:eee66eeeeee66eeeeeeeeeeeeeeeeeeeeeeeeaeeeeeeaaeeeeeeaeeeeeaeaee6
;; 202:eee66600eee66660aee66666aee66666aea66666a6666666a666666666666666
;; 203:0000000006000000660000006600000066000000660000006600000060000000
;; 208:00a6666a000a666a000066660000066600000066000000060000000000000000
;; 209:eeeaaeeea666aa66a6666a666666666666666666666666660666666600000000
;; 210:a66a6666aa6666606aa666606666666066666600666660006666000000000000
;; 212:0aeaeeea00eaeaea000aeaee0000066600000000000000000000000000000000
;; 213:eeaee666eeae6666ee6666666666660000000000000000000000000000000000
;; 214:6666000666600006600000000000000000000000000000000000000000000000
;; 215:6660000066000000660000006000000000000000000000000000000000000000
;; 216:0aeaeeea00eaeaea000aeaee0000066600000000000000000000000000000000
;; 217:eeaee666eeae6666ee6666666666600000000000000000000000000000000000
;; 218:6666000666600006000000060000000000000000000000000000000000000000
;; 219:6000000060000000000000000000000000000000000000000000000000000000
;; </TILES>

;; <SPRITES>
Expand Down Expand Up @@ -123,24 +167,40 @@
;; 051:000000cc0000bbcc00abbcbbaaaabb006aaa0000660000000000000000000000
;; 052:1210000029200000121000000000000000000000000000000000000000000000
;; 053:2010000009000000102000000000000000000000000000000000000000000000
;; 057:0000000006666660660000666000000060000000ff000000ff00000000666666
;; 058:0000000000000000600000006600000006000000066000000660000066660000
;; 059:0000000000000000000000000000000000000000000000000000000000066000
;; 060:0000000000000006000000660000066600a0666600a6666600a66a6600a66a66
;; 061:6666666666666666666666666666666666666166a6661111a6666166a6666666
;; 062:6666600066666600666666666666666666666666666666666666666666666666
;; 063:0000666000666660666666606666666066666660666666606666666066666660
;; 064:000077000ff777007ff7f7707777777007777877077888770778877000077000
;; 067:00000000000ff00000ffff000ff77ff00ff77ff000ffff00000ff00000000000
;; 068:00000000000cc00000cffc000cfff7c00cff77c000c77c00000cc00000000000
;; 072:0000000000000006000000660000066600a0666600a6666600a66a6600a66a66
;; 073:6666666666666666666666666666666666666166a6661111a6666166a6666666
;; 074:6666600066666600666666666666666666666666666666666666666666666666
;; 075:0066600066666000666660006666600066666600666666006666660066666600
;; 076:0066666600666666006666660066666600666666000666660006666600006666
;; 077:a66a6666666a66a6666666a66666666666666666666666666666666666666666
;; 078:66666666666666666a6666606666660066666600666666006666660066666000
;; 079:6666666000006660000006600000000000000000000000000000000000000000
;; 080:0000000000005550000555560006666500055555000555550000555500007000
;; 081:00000000000000000000000050000110550001105700007050f0007070070070
;; 082:000000a000000a800000aa600008888000aaa860088866800caca86006666600
;; 088:0066666600666666006666660066666600666666000666660006666600006666
;; 089:a6666666666a6666666a66a6666666a666666666666666666666666666666666
;; 090:6666666666666666666666606a66660066666600666666006666660066666000
;; 091:6666660000066600000066000000000000000000000000000000000000000000
;; 092:0000666600000666000000660000000000000000000000000000000000000000
;; 093:6666666666666666666666666666666600000000000000000000000000000000
;; 094:6666600066660000666000006000000000000000000000000000000000000000
;; 096:000f0000000700000000700000000f0001100070011000700077770000000000
;; 097:0f00f70000700000007000000007110000001100000000000000000000000000
;; 098:0606600006060000060600000006000006000000000600000000000000000000
;; 104:0000666600000666000000660000000000000000000000000000000000000000
;; 105:6666666666666666666666666666666600000000000000000000000000000000
;; 106:6666600066660000666000006000000000000000000000000000000000000000
;; 112:0002000000720000077777000000777000000777000000770000000000000000
;; 113:0000000000000000000000770000077700002770000727000077700000000000
;; 114:0000000000000000000020000007277700777777000000000000000000000000
Expand Down Expand Up @@ -182,10 +242,37 @@
;; 161:0000c00000007000000ccff000fccf88c7fff8aaf7fff88800ffffff000ffff0
;; 162:0000f00000007000000ccff000fccf8807fff8aaf7fff88800ffffff000ffff0
;; 163:0000c00000007000000ccff000fccf88c7fff8aa07fff88800ffffff000ffff0
;; 165:00000000000666600060006600600ff000066ff0000000000000000000666666
;; 166:0000000000000000600000006600000006000000066000000660000066660000
;; 176:0000c0000000a000000cccc0c0cccc88caccc8aacaccc888c0cccccc000cccc0
;; 177:0000c0000000a000000cccc000cccc88caccc8aacaccc88800cccccc000cccc0
;; 178:0000c0000000a000000cccc000cccc880accc8aacaccc88800cccccc000cccc0
;; 179:0000c0000000a000000cccc000cccc88caccc8aa0accc88800cccccc000cccc0
;; 180:000000000000000600000066000006660000066600a0666600a6666600a66a66
;; 181:666666666666666666666666666666666666666666666666a6666666a6666666
;; 182:6666600066666600666666666666666666666666666666666666666666666666
;; 183:6600000066600000666000006666000066660000666600006666000066660000
;; 193:00000000000666600066006600600000006000000006ff000000ff0000666666
;; 194:0000000000000000600000006600000006000000066000000660000066660000
;; 195:0000000000000000000000000000000000000000000000000000000006600000
;; 196:00a66a6600666666006666660066666600666666000666660006666600006666
;; 197:a6666666a666a6666666a66a6666666a66666666666666666666666666666666
;; 198:66666666666666666666666066a6660066666600666666006666660066666000
;; 199:6666000066660000666000006600000000000000000000000000000000000000
;; 208:000000000000000600000066000006660000066600a0666600a6666600a66a66
;; 209:666666666666666666666666666666666666616666661111a6666166a6666666
;; 210:6666600066666606666666666666666666666666666666666666666666666666
;; 211:6660000066600000666000006666000066660000666600006666000066660000
;; 212:0000666600000666000000660000000000000000000000000000000000000000
;; 213:6666666666666666666666666666666600000000000000000000000000000000
;; 214:6666600066660000666000006000000000000000000000000000000000000000
;; 224:00a66a6600666666006666660066666600666666006666660006666600006666
;; 225:a6666666a66a6666666a66a6666666a666666666666666666666666666666666
;; 226:6666666666666666666666606a66660066666600666666006666660066666000
;; 227:6666000006660000006600000000000000000000000000000000000000000000
;; 240:0000666600000666000000660000000000000000000000000000000000000000
;; 241:6666666666666666666666666666666600000000000000000000000000000000
;; 242:6666600066660000666000006000000000000000000000000000000000000000
;; </SPRITES>

;; <WAVES>
Expand Down Expand Up @@ -253,4 +340,3 @@
;; <PALETTE>
;; 000:141428fa0c36bbcc5218282c00ff000c0c10202d518e2e913c405591142c5d8161599dcaf2f4f60cff08201834f661ba
;; </PALETTE>

96 changes: 88 additions & 8 deletions source/main.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,17 @@
(inc self.y (* (- self.speed.y *cam*.speedy) *dt*))
(pix self.x self.y color)))

(global *bexplosion-particle* (deepcopy *particle*))
(tset *bexplosion-particle*
:update
(fn [self]
(var color 11)
(if (< self.lifetime 600)
(set color 6))
(inc self.x (+ (* (- self.speed.x *cam*.speedx) *dt*) (sin (* 0.4 (+ *tick* self.speed.y)))))
(inc self.y (* (+ self.speed.y *cam*.speedy) *dt*))
(pix self.x self.y color)))

(global *pexplosion-particle* (deepcopy *particle*))
(tset *pexplosion-particle*
:update
Expand All @@ -258,6 +269,24 @@
(inc self.y (* (+ self.speed.y *cam*.speedy) *dt*))
(pix self.x self.y color)))

(global *bcexplosion-particle* (deepcopy *particle*))
(tset *bcexplosion-particle*
:update
(fn [self]
;(trace self.lifetime)
(var color 15)
(if (< self.lifetime 200)
(set color 6)
(< self.lifetime 400)
(set color 7)
(< self.lifetime 650)
(set color 7))
(when (= (% *tick* 4) 0)
(dec self.scale 2))
(dec self.x (* *cam*.speedx *dt*))

(circ self.x self.y self.scale color)))

(global *cexplosion-particle* (deepcopy *particle*))
(tset *cexplosion-particle*
:update
Expand All @@ -276,7 +305,7 @@

(circ self.x self.y self.scale color)))

(global *particle-types* { :cexplosion *cexplosion-particle* :bubble *bubble-particle* :pixel *pixel-particle* :pexplosion *pexplosion-particle* })
(global *particle-types* { :bcexplosion *bcexplosion-particle* :bexplosion *bexplosion-particle* :cexplosion *cexplosion-particle* :bubble *bubble-particle* :pixel *pixel-particle* :pexplosion *pexplosion-particle* })

(global *emitters* [])
(global *emitter* { :x 0 :y 0 ; Emitter position
Expand Down Expand Up @@ -338,6 +367,31 @@
(global *cexplosion-emitter* (deepcopy *emitter*))
(set *cexplosion-emitter*.type :cexplosion)

;; Boss explosion
(global *bexplosion-emitter* (deepcopy *emitter*))
(set *bexplosion-emitter*.type :bexplosion)
(set *bexplosion-emitter*.num-particles 7)
(set *bexplosion-emitter*.lifetime-range { :min 700 :max 1000 })
(set *bexplosion-emitter*.scale-range { :min 3 :max 6 })
(set *bexplosion-emitter*.pos-range { :xmin 0 :xmax 6 :ymin 2 :ymax 8 })
(set *bexplosion-emitter*.speed-range { :xmin -5 :xmax 5 :ymin -50 :ymax -40 })
(tset *bexplosion-emitter*
:update
(fn [self]
(when (> self.num-particles 0)
(self:emit)
(when (> self.num-particles 4)
(self:emit :bcexplosion))
(dec self.num-particles))

(dec self.x (* *cam*.speedx *dt*))

(each [i particle (ipairs self.particles)]
(particle:update)
(if (<= particle.lifetime 0)
(table.remove self.particles i)
(dec particle.lifetime (* *dt* 1000))))))

;; Pixel explosion
(global *pexplosion-emitter* (deepcopy *emitter*))
(set *pexplosion-emitter*.type :pexplosion)
Expand Down Expand Up @@ -942,7 +996,7 @@
(fn init-enemies []
;; List of enemy types
(global *enemy-types* [ :simple-fish :stronger-fish ])
(global *enemy* { :w 8 :h 8 :speedx 50 :speedy 0 :damage 2.0 :health 2.0 :points 1 :emitter :pexplosion :flicker 0 })
(global *enemy* { :w 8 :h 8 :speedx 50 :speedy 0 :damage 2.0 :health 2.0 :points 1 :emitter :pexplosion :flicker 0 :no-flicker false })
(set *enemy*.animator
{ :current-animation :moving
:current-index 1
Expand Down Expand Up @@ -1012,11 +1066,12 @@
(inc self.y (* 0.5 (sin (* 0.05 (+ *tick* self.y)))))))

(global *energy-ball* (deepcopy *enemy*))
(set *energy-ball*.animator.animations.moving [ 265 ])
(set *energy-ball*.animator.animations.moving [ 265 323 324 ])
(set *energy-ball*.points 0)
(set *energy-ball*.health 9999)
(set *energy-ball*.speedx 130)
(set *energy-ball*.damage 20)
(set *energy-ball*.no-flicker true)

(global *follower* (deepcopy *energy-ball*))
(set *follower*.speedx 200)
Expand Down Expand Up @@ -1046,10 +1101,25 @@
;; Attack speed factor
(set *anglerfish*.asfactor 1)
(set *anglerfish*.attack-types [ :follow :energy :straight :pacifist ])
(set *anglerfish*.animator
{ :current-animation :moving
:current-index 1
:elapsed 0
:speed 150
:animations
{ :moving [ 300 312 448 420 448 312 ]
:attack [ 160 164 160 168 ] }})

(set *anglerfish*.draw
(fn [self]
(spr 300 self.x self.y 0 1 0 0 4 4)))
(animate self)
(if (and (> self.flicker 0) (< (% *tick* 5) 3))
(do (dec self.flicker))
(spr (get-animation-frame self.animator) self.x self.y 0 1 0 0 4 4))))

;(set *anglerfish*.draw
;(fn [self]
;(spr 300 self.x self.y 0 1 0 0 4 4)))

(set *anglerfish*.move
(fn [self]
Expand Down Expand Up @@ -1122,10 +1192,20 @@
(dec self.x (* 60 *dt*))))

(= self.state :attack)
(self:attack)
(do (when (not (= self.animator.current-animation :attack))
(set self.animator.current-animation :attack))
(when (= (% *tick* 30) 0)
(local emitter (deepcopy *bexplosion-emitter*))
(set emitter.x (+ self.x 9))
(set emitter.y (+ self.y 12))
;(set emitter. (+ self.y 16))
(table.insert *emitters* emitter))
(self:attack))

(= self.state :moving)
(do (when (= (% self.aframe 15) 0) ; Spawn monster
(do (when (not (= self.animator.current-animation :moving))
(set self.animator.current-animation :moving))
(when (= (% self.aframe 15) 0) ; Spawn monster
(local rn (r 0 100))
(when (< rn 40)
(local enemy (spawn-enemy :stronger-fish self.x (+ self.y 16)))
Expand Down Expand Up @@ -1263,7 +1343,7 @@
(each [shot-index shot (pairs *player*.shots)]
(when (bcollides? shot enemy) (dec enemy.health shot.damage)
;; Play sound when shot
(when (> enemy.health 0) (set enemy.flicker 18) (sfx 4 33 4 3 6))
(when (and (> enemy.health 0) (not enemy.no-flicker)) (set enemy.flicker 18) (sfx 4 33 4 3 6))
(destroy-shot shot-index)
(when (and enemy.shake (= *shake* 0)) (global *shake* 5))))

Expand Down Expand Up @@ -1556,9 +1636,9 @@
(local tycam (// (math.abs *cam*.y) 8))
(map txcam tycam 31 18 (- 0 (% (math.abs *cam*.x) 8)) (- 0 (% (math.abs *cam*.y) 8)) 0)
(update-goods)
(update-emitters)
(*player*:draw)
(update-enemies)
(update-emitters)
(draw-hud))

(fn update-camera []
Expand Down

0 comments on commit 430fc77

Please sign in to comment.