Skip to content

Commit

Permalink
Add algae bg
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandevai committed Apr 20, 2020
1 parent fb15d82 commit 2e43560
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
7 changes: 5 additions & 2 deletions source/data.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@
;; 045:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
;; 046:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
;; 047:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
;; 053:0000000000000033000000330000033000000330000033000003330000033300
;; 054:0000000000033000000330000033300003333000033300000330000033300000
;; 059:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00ee0000000000000000000000000
;; 060:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00ee0000000000000000000000000
;; 061:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
;; 062:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
;; 063:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
;; 067:0000000000000000000000000300000003000000033000000330000003330000
;; 068:0000000003300000033300000033300000033300000033000000333000000330
;; 069:0000300000003300000033000000333000003330000033300000033000000330
;; 070:3000000033000000333000000333300000033300000033300000333000003330
;; 069:0003330000033330000033300000333000003330000033300000033000000330
;; 070:3330000033330000333300000333300000033300000033300000333000003330
;; 077:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00ee0000000000000000000000000
;; 078:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00ee0000000000000000000000000
;; 079:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00ee0000000000000000000000000
Expand Down Expand Up @@ -251,3 +253,4 @@
;; <PALETTE>
;; 000:141428fa0c36bbcc5218282c00ff000c0c10202d518e2e913c405591142c5d8161599dcaf2f4f60cff08201834f661ba
;; </PALETTE>

16 changes: 14 additions & 2 deletions source/main.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
(= axis :y) (+ p0 (* *cam*.y factor))))

;; Draws a sprite that loops in the x and y axis
(fn loop-spr [id x y w h pfactor ?colorkey]
(fn loop-spr [id x y w h pfactor ?colorkey ?flip]
(spr id (- (% (parallax x pfactor :x) (+ 240 (* w 8))) (* w 8))
(- (% (parallax y pfactor :y) (+ 136 (* h 8))) (* h 8))
(or ?colorkey 0) 1 0 0 w h))
(or ?colorkey 0) 1 (or ?flip 0) 0 w h))

;; Shortcut for math.random
(fn r [a b]
Expand Down Expand Up @@ -1451,9 +1451,21 @@
(loop-spr 11 280 70 5 5 pfactor)
(loop-spr 9 120 68 2 3 pfactor))

;; Draws algae with a parallax factor pfactor
;; 67 68 69 70
;; 51 52 53 54
(fn draw-algae [pfactor]
(local positions [ 0 15 32 39 47 56 62 79 83 98 107 113 125 132 147 153 165 169 177 182 189 198 213 224 232 240 ])
(local sprites [ 51 54 51 52 52 53 54 51 54 53 51 53 51 53 54 52 54 52 51 60 54 78 79 51 52 54 ])

(for [i 1 (math.min (length positions) (length sprites)) 1]
(local pos (. positions i))
(loop-spr (. sprites i) pos (+ 136 (% pos 8)) 1 5 pfactor 0 (% pos 2))))

;; Draws background decoration
(fn draw-bg []
(draw-cave-bg 0.1)
(draw-algae 0.6)
(*bg-bubbles*:update))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down

0 comments on commit 2e43560

Please sign in to comment.