summary refs log tree commit diff
path: root/lib/death.fnl
blob: 8456827056fa7a92745e2165077cf1edf30ec970 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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}