Run pipes as linked actors in their own subfacets, to prevent a vanishing pipe from killing the game
This commit is contained in:
parent
90a6e2f41a
commit
b92bbb9741
|
@ -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) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue