summaryrefslogtreecommitdiff
path: root/src/mansion.fnl
blob: 1c11067eb4fabd96df79c75003c2da658f6a2489 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
(local bump (require :vendor.bump))
(local player (require :src.player))

(local world (bump.newWorld))

(macro inpush [...]
       `(do 
         (love.graphics.push)
         (do ,...)
         (love.graphics.pop)))



(local draw_thing (coroutine.wrap 
    (fn draw_thing []
        (var t 0)
        (var angry false)

        (local tri-a 100)
        (local tri-h (* tri-a (/ (math.sqrt 3) 2)))
        (local ell-l 20)
        (local ell-r 30)
        
        (while true
               (let [theta (/ t 10)
                     c (math.cos theta)
                     s (math.sin theta)]
	                (let [dist (math.sqrt (+ (^ (- 420 player.x) 2)
	                                         (^ (- 240 player.y) 2)))]
	                     (if (and (< dist 100) (not angry))
	                         (set angry true)
	                         (and (> dist 200) angry)
	                         (set angry false)))
	                (inpush
	                 (love.graphics.translate 420 240)
	                 
	                 (inpush
	                  (love.graphics.setLineWidth 10)
	                  (love.graphics.setColor (if angry [1 0 0 0.8] [0.7 0 0.5 0.8]))
                      (love.graphics.rotate (/ (- theta) 1.618))
                      (love.graphics.polygon :line (- (/ tri-a 2)) (- (/ tri-h 3))
                                                   (/ tri-a 2)     (- (/ tri-h 3))
                                                   0               (* 2 (/ tri-h 3))))
                     
                     (love.graphics.setLineWidth 7)
                     (love.graphics.setColor 0.8 0.8 0 0.7)
                     (love.graphics.ellipse :line (* ell-l c) (* ell-l s) ell-r (* 2 ell-r))
                     (love.graphics.setColor 0 0.8 0.8 0.7)
                     (love.graphics.ellipse :line (- (* ell-l c)) (- (* ell-l s)) ell-r (* 2 ell-r)))
                    
                    (set t (+ t (if angry 1.8 1)))
                    (coroutine.yield))))))

(var font nil)
(var title nil)
(var jerma nil)
(fn theload []
    (set font (love.graphics.newFont :assets/APL333.ttf 72))
    (set title (love.graphics.newText font :mansion))
    (set jerma (love.graphics.newImage :assets/jerma.jpg))
    (world:add :jerma 30 400  400 50))

(fn draw_jerma []
    (love.graphics.setColor  1 1 1 1)
    (let [sx (/ 400 (jerma:getWidth))
          sy (/ 50  (jerma:getHeight))]
         (love.graphics.draw jerma 30 400  0  sx sy)))

(fn draw []
    (love.graphics.setColor 0.8 0.8 0.8)
    (love.graphics.setLineWidth 10)
    (love.graphics.rectangle :line 30 80  580 370)
    (love.graphics.draw title (- 610 (title:getWidth)) -10)
    
    (draw_thing)
    (draw_jerma))

{: world
 : draw
 :load theload}