Run pipes as linked actors in their own subfacets, to prevent a vanishing pipe from killing the game

This commit is contained in:
Tony Garnock-Jones 2021-12-13 20:21:21 +01:00
parent 90a6e2f41a
commit b92bbb9741
1 changed files with 50 additions and 45 deletions

View File

@ -137,14 +137,20 @@ function spawnGame(mainDs: Ref) {
spawn linked named 'pipe-factory' {
field nextPipe: number = 0;
at gameDs {
on asserted Score(nextPipe.value) => spawnPipe(nextPipe.value++);
on asserted Score(nextPipe.value) => {
react {
const pipeNumber = nextPipe.value++;
spawn linked named ['pipe', pipeNumber] {
runPipe(pipeNumber);
}
}
}
}
}
function spawnPipe(i: number) {
function runPipe(i: number) {
const xlocation = (i + 1) * 324;
spawn linked named ['pipe', i] {
let ui = new Anchor();
field xpos: number = xlocation;
@ -193,4 +199,3 @@ function spawnGame(mainDs: Ref) {
}
}
}
}