Let's see...
You could have something like this :
globals :
- treeGrowingTick
- treeMinHeight
- treeRandomHeight
treeBase sprite :
- isActive (boolean, true on create)
- currentHeight (int, 1 on create)
- targetHeight (int)
treePart sprite :
- treeBaseID (int)
- initial frame is the top of the tree
TreeSpawning :
- spawn a "treeBase" sprite,
- set targetHeight to round(random(treeRandomHeight)+treeMinHeight),
- call "treeActualise"(treeBase.UID)
on Function treeActualise,
Pick treeBase by UID,
if treeBase.currentHeight < treeBase.targetHeight
Pick TreePart by comparaison (treeBaseID = treeBase.UID):
- wait (treeGrowingTick)
- set TreeBase frame to something more suitable
- set treePart Frame to the middle of the tree
- Spawn treePart at X=treeBase.X, Y=treeBase.Y+(treePart.PickCount+1)*treePart*height
- set treePart.treeBaseID to treeBase.ID
on Function treeDestroy (called with the treeBase UID as a parameter, making the tree base a good candidate for a "HP" variable ^^)
Pick TreePart by comparaison (treeBaseID = treeBase.UID):
- spawnLoot
- treePart.destroy
- treeBase.destroy
As you can see TheNewGuy , I've written this directly on the forums, didn't test it. I hope it does the trick :)