GOOC - Game Oriented Object C
GOOC - Game Oriented Object C
11. Spawns
11. Spawns
In order to spawn an object, its GOOL ID and spawn ID must be specified. The GOOL ID is the identification used in the output GOOL file while the spawn ID determines the initial state. The spawn ID itself is NOT the initial state. This is useful for giving two similar types of objects some separate code.
A spawn is defined using the spawn directive, in this format:
#spawn spawn-name initial-state-name
spawn-name is the name of the spawn, and initial-state-name is the name of the initial spawn state. The initial spawn state does not have to be unique or defined prior to defining the spawn, and in the case that the state does not exist at all, the spawn will instead be mapped to state 255, and the object cannot spawn. This is not undefined behavior.
When used as an expression, the spawn name translates into the spawn ID. For Crash 3, spawns in expressions will translate into the GOOL ID in the upper 16 bits, and the spawn ID in the lower 16 bits, in order to differentiate where the spawn ID is from. This is the same value that will be stored in the spawn field, when the object is spawned.
#gool Foo_C 63 1
#spawn S_FOO StateFoo
#spawn S_BAR StateFoo
state StateFoo {
code () {
x = 200.0
y = 200.0
if (spawn == S_FOO) {
x += 100.0
}
do { playframe(2.1s) } while (1)
}
}
If the selected version isn't Crash 3, S_BAR will translate into 0x1, but if the selected version is Crash 3, then it will translate into 0x3F0001.