win.fnl 1.93 KB
Newer Older
1 2
;;; win state animations

3
(local flipped {:Nikita true :Adam true :Carrie true})
4

5 6 7 8 9
(fn split-faces []
  (line 60 0 120 136 5)
  (line 180 0 120 136 5)
  (line 0 74 90 68 5)
  (line 239 74 150 68 5)
10
  (spr 387 96  6 0 3 0 0 2 2)
11 12 13 14 15
  (spr 323 8   12 0 3 0 0 2 2)
  (spr 291 184 12 0 3 0 0 2 2)
  (spr 355 32  80 0 3 0 0 2 2)
  (spr 259 160 80 0 3 0 0 2 2))

16
(var (rx rdx) nil)
17

18 19 20 21 22 23 24
(fn draw-win []
  (cls)
  (draw-stars 0 scroll-x)
  (each [name mech (pairs mechs)]
    (spr mech.spr mech.x mech.y 0 1
         (if (. flipped name) 1 0)
         3 4 2))
25 26 27 28 29 30 31
  (when (<= -220 mechs.Nikita.y -40)
    (split-faces)
    (when (<= mechs.Nikita.y -72)
      (print "FORM RHINOCELATOR!" 16 64 15 false 2))
    (when (<= mechs.Nikita.y -150)
      (print "YEAH" 90 80 15 false 3)))
  (when (<= mechs.Nikita.y -220)
32 33
    (set rx (+ rx rdx))
    (set rdx (+ rdx 0.02))
34 35
    (if (< rx 48)
        (set mx (- mx 0.7))
36
        (set mx (+ mx (* rdx 1.2))))
37 38
    (spr 261 rx 16 0 1 0 0 6 8)
    (spr 268 mx my 0 1 0 0 4 6)
39 40 41 42
    (when (<= mechs.Nikita.y -255)
      (set-dialog (fn [] (say-as :Carrie "That's right; you better run!"))))
    (when (< 300 rx)
      (set said nil)
43
      (print "Earth is safe" 46 16 15 false 2)
44
      (print "YOU WIN" 42 48 15 false 4)
45
      (print "thanks for playing!" 68 120 2)
46 47
      (print "press ESC to see how the game was made" 16 130 2)))
  (draw-dialog :helmet))
48 49

(fn win []
50
  (set scroll-x (- scroll-x 3))
51 52 53 54 55
  (each [name mech (pairs mechs)]
    (set mech.x (lerp mech.x 120 0.009))
    (set mech.y (- mech.y 1)))
  (draw-win))

56 57
(set enter-win
     (fn []
Emma Bukacek's avatar
Emma Bukacek committed
58
       (music 0 0)
59
       (set said nil)
60 61 62 63 64 65 66
       (set (scroll-x rx rdx mx my) (values 0 16 0.5 168 28))
       (let [init-ys {:Adam 8 :Turk 8 :Carrie 0 :Hank 12 :Nikita 12}
             init-xs {:Adam 100 :Turk 40 :Carrie 68 :Hank 15 :Nikita 120}]
         (each [name mech (pairs mechs)]
           (set mech.x (* (. init-xs name) 1.8))
           (set mech.y (+ 128 (. init-ys name)))))
       (global TIC win)))