1.0
03 Apr 2018 18:58
array<bool> 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;
}
}
}
}
}
Jazz2Online © 1999-INFINITY (Site Credits). We have a Privacy Policy. Jazz Jackrabbit, Jazz Jackrabbit 2, Jazz Jackrabbit Advance and all related trademarks and media are ™ and © Epic Games. Lori Jackrabbit is © Dean Dodrill. J2O development powered by Loops of Fury and Chemical Beats.
Eat your lima beans, Johnny.