summaryrefslogtreecommitdiff
path: root/bonnie-bee/boss.scm
blob: d19f2c24626ffbbc4a3a7d85965594c62cac20cc (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
(define-module (bonnie-bee boss)
  #:use-module (bonnie-bee actor)
  #:use-module (bonnie-bee assets)
  #:use-module (bonnie-bee bullet)
  #:use-module (chickadee audio)
  #:use-module (chickadee graphics particles)
  #:use-module (chickadee math)
  #:use-module (chickadee math rect)
  #:use-module (chickadee math vector)
  #:use-module (chickadee scripting)
  #:use-module (chickadee utils)
  #:use-module (oop goops)
  #:use-module (starling asset)
  #:use-module (starling node)
  #:use-module (starling node-2d)
  #:export (<boss>))

(define-class <boss> (<grounded> <damageable> <actor>))

(define-method (on-boot (boss <boss>))
  (attach-to boss
             (make <sprite>
               #:texture beetle-image
               #:origin (vec2 64.0 32.0))))

(define-method (on-collide (boss <boss>) (bullet <bullet>))
  (cond
   ((player-primary-bullet? bullet)
    (damage boss 1)
    (kill-bullet bullet)
    #t)
   ((player-bomb-bullet? bullet)
    (damage boss 10)
    (kill-bullet bullet))
   (else #f)))

(define-method (on-death (boss <boss>))
  (audio-play (asset-ref explosion-sound))
  (add-particle-emitter (particles (particles (parent boss)))
                        (make-particle-emitter (world-hitbox boss) 20 30)))