summary refs log tree commit diff
path: root/lib/death.fnl
diff options
context:
space:
mode:
authorequa <equaa@protonmail.com>2021-04-20 18:20:05 -0500
committerequa <equaa@protonmail.com>2021-04-20 18:20:05 -0500
commitc9b60c569f2ad015f043667c44ff9f43d50ec2e5 (patch)
treef4a3bb3f363a5a3c9200bc8ee5a9eab408085a1c /lib/death.fnl
parent00af64d4e503dd82abf4657ec6fd44b0a418adb2 (diff)
death screen
Diffstat (limited to 'lib/death.fnl')
-rw-r--r--lib/death.fnl35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/death.fnl b/lib/death.fnl
new file mode 100644
index 0000000..8456827
--- /dev/null
+++ b/lib/death.fnl
@@ -0,0 +1,35 @@
+(local state (require :lib.state))
+(local font (require :lib.font))
+
+(fn draw [self]
+  (local (width height) (love.graphics.getDimensions))
+  (state.draw self.present-state)
+  ;; TODO: translation
+  (love.graphics.reset)
+  (love.graphics.setColor 0.8 0.8 0.8 (/ (math.max 0 (- self.age 30)) 10))
+  (love.graphics.setFont font.big)
+  (love.graphics.printf "moli a" (- (/ width 2) 500) (- (/ height 2) 64) 1000 :center)
+  (love.graphics.setFont font.small)
+  (love.graphics.printf "nena Z li open e musi sin" (- (/ width 2) 500) (+ (/ height 2)) 1000 :center))
+
+(fn update [self]
+  ;; TODO: actually update in case it returns something else
+  (state.update self.present-state)
+  (set self.age (math.min 40 (+ self.age 1)))
+  (if self.transition
+      self.future-state
+      nil))
+
+(fn keypressed [self key scancode repeat]
+  (when (and (not repeat) (= key :z))
+    (set self.transition true))
+  )
+
+(fn init [self present-state future-state]
+  (setmetatable
+    {: present-state
+     : future-state
+     :age 0}
+    self))
+
+{state.draw draw state.init init state.update update state.keypressed keypressed}