This repository has been archived by the owner on May 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lisp
695 lines (591 loc) · 22.2 KB
/
main.lisp
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
(import love/love (defevent))
(import love/graphics)
(import love/physics)
(import love/image)
(import love/window)
(import love/keyboard)
(import love/audio)
(import love/timer ())
(import lua/math (floor))
; import from helpers.lisp
(import helpers ())
(import love-helpers ())
(import timer timer)
(define love :hidden (require "love"))
(define anim8 :hidden (require "anim8"))
(define new-animation (.> anim8 :newAnimation))
(define new-grid (.> anim8 :newGrid))
(define flux :hidden (require "flux"))
(define flux/update (.> flux :update))
(define fonts '())
(define font-index :mutable 1)
(define last-font-time :mutable (get-time))
; time to switch between fonts
(define font-delay-time 0.5)
(define dog-home-x 192)
(define dog-home-y 400)
; how much force applied on wasd
(define dog-movement-impulse 100)
; game objects
(define scene :mutable "title")
(define score :mutable 0)
(define remaining-time :mutable 30)
(define world :mutable nil)
(define canvas :mutable nil)
(define dog :mutable nil)
(define foods :mutable '())
(define title-menu-options '("new game" "how to play" "credits"))
(define title-menu-index :mutable 1)
(defun title-menu-next-index (delta)
(let [(next-index (+ delta title-menu-index))]
(cond
[(> next-index (n title-menu-options)) title-menu-index]
[(< next-index 1) title-menu-index]
[true next-index])))
(defun new-ground ()
(let* [(body (love/physics/new-body world (/ 800 2) 1000 "static"))
(shape (love/physics/new-rectangle-shape 800 25))
(fixture (love/physics/new-fixture body shape))]
(self fixture :setUserData {:type :ground})
(self fixture :setFriction 0.9)
{ :body body :shape shape :fixture fixture }))
(defun new-left-wall ()
(let* [(body (love/physics/new-body world -100 (/ 800 2) "static"))
(shape (love/physics/new-rectangle-shape 50 1500))
(fixture (love/physics/new-fixture body shape))]
(self fixture :setFriction 0.9)
{ :body body :shape shape :fixture fixture }))
(defun new-right-wall ()
(let* [(body (love/physics/new-body world 900 (/ 800 2) "static"))
(shape (love/physics/new-rectangle-shape 50 1500))
(fixture (love/physics/new-fixture body shape))]
(self fixture :setFriction 0.9)
{ :body body :shape shape :fixture fixture }))
(define dog-open-mouth-time 0.5)
(defun dog-open-mouth-stuff (dog)
(self (.> dog :dog-bottom-face-fixture) :setSensor true)
(.<! dog :mouth-open-duration 0))
(defun dog-closed-mouth-stuff (dog)
(self (.> dog :dog-bottom-face-fixture) :setSensor false))
(defun set-dog-state (dog new-state)
(let [(cur-state (.> dog :state))]
(.<! dog :state new-state)
(.<! dog :anim (.> (.> dog :anims) new-state))
(self (.> dog :anim) :resume)
(when (and (= cur-state :open) (dog-has-food? dog))
(dog-eat-food dog)
(self (.> sounds :eat) :play))
(when (= cur-state :open)
(dog-open-mouth-stuff dog))
(when (= cur-state :closed)
(dog-closed-mouth-stuff dog))))
(defun dog-advance-state (dog)
(let* [(cur-state (.> dog :state))
(next-state (case cur-state
[:closed :opening]
[:opening :open]
[:open :closing]
[:closing :closed]))]
(set-dog-state dog next-state)))
(defun dog-maybe-catch-food (dog)
(when (and (= :open (.> dog :state))
(not (dog-has-food? dog)))
(map (lambda (contact)
(let* [(fixtures (pself contact :getFixtures))
(fix-a (car fixtures))
(fix-b (cadr fixtures))]
(collision-with
:food :dog-mouth fix-a fix-b
(lambda (food-fixture _) (dog-catch-food dog food-fixture)))))
(filter (lambda (contact) (self contact :isTouching))
(values (self (.> dog :body) :getContacts))))))
(defun dog-has-food? (dog) (not (= nil (.> dog :has-food-type))))
(defun dog-catch-food (dog food-fixture)
(.<! dog :has-food-type (.> (self food-fixture :getUserData) :food-type))
(fixture-tell-body-to-die food-fixture)
(dog-advance-state dog))
(defun dog-eat-food (dog)
(set! score (+ score 1))
(.<! dog :has-food-type nil))
(defun dog-update (dt)
(dog-maybe-catch-food dog)
(let* [(body (.> dog :body))
(cur-angle (self body :getAngle))]
(self body :applyAngularImpulse (* -1000 cur-angle)))
(when (= :open (.> dog :state))
(.<! dog :mouth-open-duration (+ (.> dog :mouth-open-duration) dt))
(when (> (.> dog :mouth-open-duration) dog-open-mouth-time)
(dog-advance-state dog))))
(defun new-fixture (body fixture-data is-sensor shape)
(let [(fixture (love/physics/new-fixture body shape))]
(self fixture :setUserData fixture-data)
(self fixture :setSensor is-sensor)
fixture))
;; turns a list of point lists into a list of shifted points (not a list of shifted list points mind you)
(defun shift-vertices (x y point-alist)
(flat-map (lambda (lst) (list (+ x (car lst)) (+ y (cadr lst))))
point-alist))
(defun new-dog ()
(let* [(body (love/physics/new-body world dog-home-x dog-home-y "dynamic"))
(dog-bottom-face-fixture
(new-fixture body
{:type :dog}
false
(apply love/physics/new-polygon-shape
(shift-vertices -40 -60
'((0 62)
(86 62)
(138 86)
(0 92))))))
(dog {:body body
:state nil
:anim nil
:anims nil
:dog-bottom-face-fixture dog-bottom-face-fixture
:dog-sprite-origin '(-60 -95)
:food-sprite-origin '(70 -20)
:mouth-open-duration 0
:has-food-type nil})
(anims {:closed (new-animation (.> frames :dog-closed) 0.1 "pauseAtEnd")
:opening (new-animation (.> frames :dog-opening)
0.1
(lambda () (dog-advance-state dog)))
:open (new-animation (.> frames :dog-open) 0.1 "pauseAtEnd")
:closing (new-animation (.> frames :dog-closing)
0.1
(lambda () (dog-advance-state dog)))})]
(.<! dog :anims anims)
(self body :setGravityScale 0) ; no gravity on the dog plz
(self body :setAngularDamping 8) ; stop spinning one day
(self body :setLinearDamping 2)
(new-fixture
body
{:type :dog}
false
(apply love/physics/new-polygon-shape
(shift-vertices -40 -60
'((0 0)
(68 0)
(148 8)
(148 26)
(86 62)
(0 62)))))
(new-fixture body
{:type :dog-mouth}
true
(love/physics/new-rectangle-shape 80 10 50 20 0.1))
(set-dog-state dog :closed)
dog))
(defun draw-on-body (body animation sheet local-point)
(apply self animation :draw
sheet
`(,@(pself body :getWorldPoint (nth local-point 1) (nth local-point 2))
,(self body :getAngle)
1 1)))
(defun draw-dog (dog)
(when (dog-has-food? dog)
(with (food (.> dog :has-food-type))
(draw-on-body (.> dog :body)
(.> food-stills food)
(.> food-sheets food)
(.> dog :food-sprite-origin))))
(draw-on-body (.> dog :body)
(.> dog :anim)
dog-sheet
(.> dog :dog-sprite-origin)))
(defun spawn-food ()
(set! foods (cons (new-food) foods)))
(defun new-food ()
(let* [
(init-x (random-range 600 900))
(init-y (random-range 400 800))
(init-impulse-x (random-range -100 -60))
(init-impulse-y (random-range -150 -100))
(body (love/physics/new-body world init-x init-y "dynamic"))
; (shape (love/physics/new-circle-shape 32))
(shape (apply
love/physics/new-polygon-shape
(shift-vertices 0 0
'((-30 12)
(-30 12)
(-12 30)
(12 30)
(30 12)
(30 -12)
(12 -30)
(-12 -30)))))
(fixture (love/physics/new-fixture body shape))
(anim (new-animation (.> frames :doughnut) 0.15))
(sheet-key (sample (keys food-sheets)))]
(self fixture :setDensity 1.5)
(self body :resetMassData)
(self fixture :setFriction 0.5)
(self body :applyLinearImpulse init-impulse-x init-impulse-y)
(self fixture :setUserData {:type :food :food-type sheet-key})
(self body :setAngularVelocity 0.1)
{ :body body :shape shape :fixture fixture :anim anim :sheet-key sheet-key })
)
; imports 4x sheet
(defun import-sheet (path)
(let [(image (love/graphics/new-image path))]
; (self image :setFilter "nearest" "nearest")
image))
; anim8 assets: sheets, grids n frames
(define food-sheets {
:doughnut (import-sheet "assets/doughnut4x.png")
:taco (import-sheet "assets/taco4x.png")
:hotdog (import-sheet "assets/hotdog4x.png")
:strawberry (import-sheet "assets/strawberry4x.png")
:broccoli (import-sheet "assets/broccoli4x.png")
})
(define dog-sheet (import-sheet "assets/dog-e-dog4x.png"))
(define sounds
{:throw (love/audio/new-source "assets/throw.wav" "static")
:eat (love/audio/new-source "assets/eat.wav" "static")
:splat (love/audio/new-source "assets/splat.wav" "static")
:music (love/audio/new-source "assets/catdogsong.wav" "static")})
(self (.> sounds :music) :setLooping true)
(self (.> sounds :music) :setVolume 0.2)
(self (.> sounds :splat) :setVolume 0.3)
(define grids {
;; assuming all food is 16x16 at 4x with 4 frames
:food (new-grid
64
64
(self (.> food-sheets :doughnut) :getWidth)
(self (.> food-sheets :doughnut) :getHeight))
:dog (new-grid
192
192
(self dog-sheet :getWidth)
(self dog-sheet :getHeight))
})
(define frames {
:doughnut (self (.> grids :food) :getFrames "1-4" 1)
:dog-closed (self (.> grids :dog) :getFrames 1 1)
:dog-opening (self (.> grids :dog) :getFrames "2-3" 1)
:dog-open (self (.> grids :dog) :getFrames 3 1)
:dog-closing (self (.> grids :dog) :getFrames "4-5" 1)
})
(define food-stills
{:doughnut (new-animation (self (.> grids :food) :getFrames 1 1) 0.1 "pauseAtEnd")
:taco (new-animation (self (.> grids :food) :getFrames 1 1) 0.1 "pauseAtEnd")
:hotdog (new-animation (self (.> grids :food) :getFrames 1 1) 0.1 "pauseAtEnd")
:strawberry (new-animation (self (.> grids :food) :getFrames 1 1) 0.1 "pauseAtEnd")
:broccoli (new-animation (self (.> grids :food) :getFrames 1 1) 0.1 "pauseAtEnd")
})
; sets angle on a love.physics body, between the min and max angles (in radians)
(defun set-angle (body angle-delta min-angle max-angle)
(let* [(old-angle (self body :getAngle))
(new-angle (bounded (+ old-angle angle-delta)
min-angle
max-angle))]
(when (/= old-angle new-angle)
(self body :setAngle new-angle))))
(defun collision-with (type-a type-b fixture-a fixture-b fn)
(let [(data-a (.> (self fixture-a :getUserData)))
(data-b (.> (self fixture-b :getUserData)))]
(when (and (not (nil? data-a)) (not (nil? data-b)))
(let [(test-a (.> (self fixture-a :getUserData) :type))
(test-b (.> (self fixture-b :getUserData) :type))]
(cond [(and (= type-a test-a) (= type-b test-b))
(fn fixture-a fixture-b)]
[(and (= type-a test-b) (= type-b test-a))
(fn fixture-b fixture-a)]
[true nil])))))
(defun fixture-tell-body-to-die (fixture)
(self (self fixture :getBody) :setUserData true))
; callback for collision detection
(defun begin-contact (a b coll)
(collision-with
:food :dog a b
(lambda (food-fixture)
(let [(speed (body/get-speed (fixture/get-body food-fixture)))]
(when (> speed 200)
(self (.> sounds :splat) :play))))
))
(defun is-destroyed? (body)
(self body :isDestroyed))
(defun destroy-all-food (foods)
(do [(food (exclude is-destroyed? (map (lambda (x) (.> x :body)) foods)))]
(self food :setUserData true)))
(defun reset-game ()
(set! score 0)
(set! remaining-time 30)
(destroy-all-food foods))
(defun on-keypress (key is-repeat)
(when (= key "m")
(love/audio/set-volume (- 1 (love/audio/get-volume))))
(when (= scene "title")
(when (or (= key "s") (= key "down"))
(set! title-menu-index (title-menu-next-index 1)))
(when (or (= key "w") (= key "up"))
(set! title-menu-index (title-menu-next-index -1)))
(when (= key "return")
(when (= (nth title-menu-options title-menu-index) "new game")
(set! scene "game"))
(when (= (nth title-menu-options title-menu-index) "how to play")
(set! scene "how-to"))
(when (= (nth title-menu-options title-menu-index) "credits")
(set! scene "credits"))))
(when (= scene "game")
(when (= key "escape")
(reset-game)
(set! scene "title"))
(when (= key "space")
(when (= (.> dog :state) :closed)
(dog-advance-state dog)))
(when (= key "a")
(body/apply-linear-impulse-vector
(.> dog :body)
{ :x (- 0 dog-movement-impulse) :y 0 }))
(when (= key "d")
(body/apply-linear-impulse-vector
(.> dog :body)
{ :x dog-movement-impulse :y 0 }))
(when (= key "w")
(body/apply-linear-impulse-vector
(.> dog :body)
{ :x 0 :y (- 0 dog-movement-impulse) }))
(when (= key "s")
(body/apply-linear-impulse-vector
(.> dog :body)
{ :x 0 :y dog-movement-impulse })))
(when (= scene "how-to")
(when (= key "escape")
(set! scene "title")))
(when (= scene "credits")
(when (= key "escape")
(set! scene "title")))
(when (= scene "game-over")
(when (= key "escape")
(reset-game)
(set! scene "title")))
)
(define sun-position {:x 300 :y 0})
(make-tween st1 st2
sun-position
3
{:x 320 :y -10})
(make-tween st2 st3
sun-position
3
{:x 300 :y -10})
(make-tween st3 st1
sun-position
3
{:x 300 :y 0})
(define close-grass-position {:x -50 :y 400})
(make-tween close-grass-1 close-grass-2
close-grass-position
3
{:x -45})
(make-tween close-grass-2 close-grass-1
close-grass-position
3
{:x -50})
(define mid-grass-position {:x -50 :y 400})
(make-tween mid-grass-1 mid-grass-2
mid-grass-position
3
{:x -53})
(make-tween mid-grass-2 mid-grass-1
mid-grass-position
3
{:x -50})
(define far-grass-position {:x -50 :y 400})
(make-tween far-grass-1 far-grass-2
far-grass-position
3
{:x -48})
(make-tween far-grass-2 far-grass-1
far-grass-position
3
{:x -50})
(defevent :load ()
(push! fonts (love/graphics/new-image-font
"assets/test-font1.png"
" abcdefghijklmnopqrstuvwxyz0123456789.,'!?"))
(push! fonts (love/graphics/new-image-font
"assets/test-font2.png"
" abcdefghijklmnopqrstuvwxyz0123456789.,'!?"))
(love/window/set-mode 800 800 { :display 2 })
(love/physics/set-meter 192)
(set! world (love/physics/new-world 0 (* 9.81 192) true))
(new-left-wall)
(new-ground)
(new-right-wall)
(set! dog (new-dog))
;; start some tweens
(st1)
(close-grass-1)
(mid-grass-1)
(far-grass-1)
; callbacks?
(self world :setCallbacks begin-contact nil nil nil)
; one-shot keys
(.<! love :keypressed on-keypress)
; setup callback for food spawning
(timer/on-percent-chance 0.5 0.25 (lambda () (spawn-food)))
)
(defun update-music ()
(when (not (= scene "game"))
(with (music (.> sounds :music))
(when (self music :isPlaying)
(self music :stop))))
(when (= scene "game")
(with (music (.> sounds :music))
(when (not (self music :isPlaying))
(self music :play)))))
(defevent :update (dt)
(when (= scene "title"))
(when (= scene "game")
(flux/update dt)
(self world :update dt)
(self (.> dog :anim) :update dt)
(dog-update dt)
(timer/update dt)
(set! remaining-time (- remaining-time dt))
; push the dog back to its home by applying force in opposite direction
(let* [(body (.> dog :body))
(vector-home (body/vector-to body dog-home-x dog-home-y))
(vector-scaled (scale-vector vector-home 2))
(x (- 0 (.> vector-scaled :x)))
(y (- 0 (.> vector-scaled :y)))]
(self body :applyForce x y))
; update food list, destroy if marked for destruction
; pause animation if moving too slowly
(do [(food foods)]
(let* [(body (.> food :body))
(anim (.> food :anim))
(sheet (.> food-sheets (.> food :sheet-key)))]
(self anim :update dt)
(when (not (self body :isDestroyed))
(when (< (body/get-speed body) 100)
(self anim :pause))
(when (self body :getUserData)
(self body :destroy)))
))
(when (love/keyboard/is-down "j")
(set-angle (.> dog :body) -0.1 -1 1))
(when (love/keyboard/is-down "k")
(set-angle (.> dog :body) 0.1 -1 1))
; game over logic
(when (<=(- remaining-time dt) 0)
(set! scene "game-over")))
(update-music))
(define bg-sky (love/graphics/new-image "assets/sky.png"))
(define bg-sun (love/graphics/new-image "assets/sun.png"))
(define close-grass (love/graphics/new-image "assets/close-grass.png"))
(define mid-grass (love/graphics/new-image "assets/mid-grass.png"))
(define far-grass (love/graphics/new-image "assets/far-grass.png"))
(define title-image (love/graphics/new-image "assets/title.png"))
(defun draw-sun ()
(love/graphics/set-color 1 1 1 1)
(love/graphics/draw bg-sun (.> sun-position :x) (.> sun-position :y)))
(defun draw-bg ()
(love/graphics/draw bg-sky 0 0)
(love/graphics/set-color 0.2 0.2 1 0.2)
(love/graphics/rectangle "fill" 0 0 800 800)
(draw-sun)
(love/graphics/set-color 0.2 0.2 1 0.1)
(love/graphics/rectangle "fill" 0 0 800 800)
(love/graphics/set-color 1 1 1 1)
(love/graphics/draw far-grass
(.> far-grass-position :x)
(.> far-grass-position :y))
(love/graphics/draw mid-grass
(.> mid-grass-position :x)
(.> mid-grass-position :y)))
(defun draw-fg ()
(love/graphics/set-color 1 1 1 1)
(love/graphics/draw close-grass
(.> close-grass-position :x)
(.> close-grass-position :y)))
(defun draw-ui ()
(love/graphics/set-color 0 0 0 0.2)
(love/graphics/print "time left" 20 20)
(love/graphics/set-color 1 1 1 1)
(love/graphics/print "time left" 22 22)
(love/graphics/set-color 0 0 0 0.2)
(love/graphics/print (floor remaining-time) 380 22)
(love/graphics/set-color 1 1 1 1)
(love/graphics/print (floor remaining-time) 380 22)
(love/graphics/set-color 0 0 0 0.2)
(love/graphics/print score 700 22)
(love/graphics/set-color 1 1 1 1)
(love/graphics/print score 700 20))
(defun draw-menu ()
(do ([option title-menu-options])
(let [(index (element-index option title-menu-options))]
; draw a little shadow
(love/graphics/set-color 0 0 0 0.2)
(love/graphics/print option 242 (+ 462 (* 80 index)))
; set color red if selected
(if (= title-menu-index index)
(love/graphics/set-color 1 0 0 1)
(love/graphics/set-color 1 1 1 1))
(love/graphics/print option 240 (+ 460 (* 80 index))))
; reset color for others
(love/graphics/set-color 1 1 1 1)))
(defun draw-how-to ()
(love/graphics/set-color 0 0 0 0.5)
(love/graphics/print "catch all the food!" 42 162)
(love/graphics/print "wasd to move around!" 42 242)
(love/graphics/print "space to open mouth!" 42 322)
(love/graphics/print "j or k to tilt head!" 42 402)
(love/graphics/print "m to mute the sound!" 42 482)
(love/graphics/print "esc back to title!" 42 562)
(love/graphics/set-color 1 1 1 1)
(love/graphics/print "catch all the food!" 40 160)
(love/graphics/print "wasd to move around!" 40 240)
(love/graphics/print "space to open mouth!" 40 320)
(love/graphics/print "j or k to tilt head!" 40 400)
(love/graphics/print "m to mute the sound!" 40 480)
(love/graphics/print "esc back to title!" 40 560))
(defun draw-credits ()
(love/graphics/set-color 0 0 0 0.5)
(love/graphics/print "eric buckthal" 42 242)
(love/graphics/print "massimo siboldi" 42 322)
(love/graphics/print "harmony dashut" 42 402)
(love/graphics/set-color 1 1 1 1)
(love/graphics/print "eric buckthal" 40 240)
(love/graphics/print "massimo siboldi" 40 320)
(love/graphics/print "harmony dashut" 40 400))
(defevent :draw ()
; do update for which font to draw
(when (> (get-time) (+ font-delay-time last-font-time))
(set! font-index (if (= 1 font-index) 2 1))
(set! last-font-time (get-time))
(love/graphics/set-font (nth fonts font-index) 8))
(when (= scene "title")
(draw-bg)
(love/graphics/draw title-image 0 50)
(draw-menu))
(when (= scene "how-to")
(draw-bg)
(draw-how-to))
(when (= scene "credits")
(draw-bg)
(draw-credits))
(when (= scene "game")
(draw-bg)
(draw-dog dog)
; just draw all foods
(do [(food foods)]
(let* [(body (.> food :body))
(anim (.> food :anim))
(sheet (.> food-sheets (.> food :sheet-key)))]
(when (not (self body :isDestroyed))
(self anim :draw
sheet (body/get-x body) (body/get-y body) 0 1 1 32 32))))
; must set color back to white at end of draw
(love/graphics/set-color 1 1 1)
(draw-fg)
(draw-ui))
(when (= scene "game-over")
(draw-bg)
(love/graphics/print "game over!" 40 240)
(love/graphics/print score 40 320)
(love/graphics/print "foods eaten" 150 320))
)