summaryrefslogtreecommitdiff
path: root/game.fnl
diff options
context:
space:
mode:
authorJakob L. Kreuze <jakob@memeware.net>2018-10-22 08:54:50 -0400
committerJakob L. Kreuze <jakob@memeware.net>2018-10-22 08:54:50 -0400
commitb03bd19a4e5e1ee058e2fbcba8b72dca247137e3 (patch)
tree1c4f9dcb6db7109068a3f34c7a37b8abef7be92f /game.fnl
parent9c6da23443c7c10aef35b8d2a558b1cf664d2001 (diff)
Initial slimed surface counting
Diffstat (limited to 'game.fnl')
-rw-r--r--game.fnl27
1 files changed, 19 insertions, 8 deletions
diff --git a/game.fnl b/game.fnl
index 720642e..d97fdfe 100644
--- a/game.fnl
+++ b/game.fnl
@@ -168,7 +168,10 @@
(. player :frame)
(. player :orientation)
x
- y)))
+ y))
+ (love.graphics.print (string.format "%d/%d" (. world :surfaces-slimed)
+ (. world :surfaces-total))
+ 0 0))
(fn update [dt set-mode]
(local gravity 128)
@@ -227,20 +230,28 @@
(let [tile (. collision :other)]
;; Touching top.
(when (> 0 (. collision :normal :y))
- (tset tile :slimed :top true)
- (tset player :grounded true))
+ (tset player :grounded true)
+ (when (not (. tile :slimed :top))
+ (tset world :surfaces-slimed (+ 1 (. world :surfaces-slimed)))
+ (tset tile :slimed :top true)))
;; Touching bottom.
(when (< 0 (. collision :normal :y))
- (tset tile :slimed :bottom true))
-
+ (when (not (. tile :slimed :bottom))
+ (tset world :surfaces-slimed (+ 1 (. world :surfaces-slimed)))
+ (tset tile :slimed :bottom true)))
+
;; Touching left.
(when (> 0 (. collision :normal :x))
- (tset tile :slimed :left true))
+ (when (not (. tile :slimed :left))
+ (tset world :surfaces-slimed (+ 1 (. world :surfaces-slimed)))
+ (tset tile :slimed :left true)))
;; Touching right.
(when (< 0 (. collision :normal :x))
- (tset tile :slimed :right true)))))))
+ (when (not (. tile :slimed :right))
+ (tset world :surfaces-slimed (+ 1 (. world :surfaces-slimed)))
+ (tset tile :slimed :right true))))))))
(fn keypressed [key set-mode]
@@ -256,7 +267,7 @@
(fn keyreleased [key set-mode]
(when (= key "right")
(tset player :action :right false))
-
+
(when (= key "left")
(tset player :action :left false))