examples

camera-follow.js

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
world.frame(0,0,1920,1280)

repeat(20, () => {
  display.emoji("🦄", random.pos())
  display.emoji("⭐️", random.pos())
  display.emoji("🌈", random.pos())
})

pl = display.emoji("🤩", random.pos())

camera.follow(pl)

update(() => {
  pl.pointTo(input)
  pl.move(5)
})

collision = (e) => {
  let other = e.other
  //print(other.tag)
  if (pl.tag == "starstruck") {
    if (other.tag == "unicorn") {
      pl = camera.follow(other)
      pl.collision(collision)
    }
    if (other.tag == "native_2b50") { 
      other.hide() 
    }
  }
  if (pl.tag == "unicorn") {
    if (other.tag == "starstruck") {
      pl = camera.follow(other)
      pl.collision(collision)
    }
    if (other.tag == "rainbow") { 
      other.hide() 
    }
  }
  
}

pl.collision(collision)