/* Extendable Checkpoints 1.0, by Violet CLM http://www.jazz2online.com/snippets/146/extendable-checkpoints/ */ array SavedTriggers(32, false); //you will need some way to keep track of whatever information you want saved... a global variable is the simplest choice void onLevelLoad() { jjObjectPresets[OBJECT::SAVEPOST].behavior = CheckpointWrapper; jjObjectPresets[OBJECT::SAVEPOST].deactivates = false; } void onLevelReload() { //restore the state of the saved properties to how they were last time you visited a checkpoint for (uint i = 0; i < 32; ++i) jjTriggers[i] = SavedTriggers[i]; //although this example uses jjTriggers, other things should work as well } void CheckpointWrapper(jjOBJ@ obj) { if (obj.state == STATE::STOP) { //don't do anything anymore jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame); } else if (obj.state == STATE::DEACTIVATE) { //due to death obj.deactivate(); } else { obj.behave(BEHAVIOR::CHECKPOINT); if (obj.state == STATE::DONE) { //triggered by the player hitting it obj.state = STATE::STOP; //save the current state of some properties for (uint i = 0; i < 32; ++i) SavedTriggers[i] = jjTriggers[i]; //OPTIONAL: this loop makes checkpoints reusable, so only the most recent checkpoint you touched is ever active for (int i = jjObjectCount; --i > 0;) { jjOBJ@ obj2 = jjObjects[i]; if (obj2.eventID == OBJECT::CHECKPOINT && i != obj.objectID && obj2.isActive) { obj2.state = STATE::SLEEP; obj2.var[0] = 0; } } } } }