blob: e62dcb8db8f5179a6740962f2b35074648567750 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
(local state (require :lib.state))
(local font (require :lib.font))
(local translation (require :lib.translation))
(local music-state (require :lib.music-state))
(fn draw [self]
(local (width height) (love.graphics.getDimensions))
(state.draw self.present-state)
;; TODO: translation
(love.graphics.reset)
(love.graphics.translate (/ width 2) (/ height 2))
;; TODO: this scaling is pretty limited and should probably get bigger!
(local scale (if (> height 600)
2
1))
(love.graphics.setColor 0.8 0.8 0.8 (/ (math.max 0 (- self.age 30)) 10))
(love.graphics.setFont (. font (* 48 scale)))
(love.graphics.printf (string.format
(. translation.text self.type 1)
(and self.level (translation.text.number self.level)))
(* scale -500)
(* scale -64)
(* scale 1000)
:center)
(love.graphics.setFont (. font (* 12 scale)))
(love.graphics.printf (string.format
(. translation.text self.type 2)
(and self.level (translation.text.number self.level)))
(* scale -500)
0
(* scale 1000)
:center))
(fn update [self]
;; TODO: actually update in case it returns something else
(when (not= self.type :pause)
(state.update self.present-state))
(when (= self.type :pause)
(set music-state.screen :pause))
(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) (or (and (= self.type :pause)
(= key :escape))
(= key :z)))
(set self.transition true))
)
(fn init [self type present-state future-state level]
(setmetatable
{: type
: present-state
: level
: future-state
:age (if (or (= type :pause) (= type :menu)) 40 0)}
self))
{state.draw draw state.init init state.update update state.keypressed keypressed}
|