Page 1 of 1

check points

PostPosted: Wed Mar 04, 2009 3:09 am
by refresh
how do i script these?

(how to make a checkpoint)

Re: check points

PostPosted: Wed Mar 04, 2009 5:19 am
by skydereign
Are you talking about save/load checkpoints? If so there are lots of demos on this, but the basics would be saving a variable, such as xy position.
If you are talking about a player's last checkpoint, which I believe you are, when you pass the checkpoint event, use
Code: Select all
checkpoint++;

Then on destroy actor, or your reinitializing event, a switch.
Code: Select all
switch (checkpoint)
{
  case 0:
  // Create actor at beggining
  break;
  case 1:
  // Create actor at checkpoint 1
  break;
  case 2:
  // Create actor at checkpoint 2
  break;
  // And so on...
}

Re: check points

PostPosted: Wed Mar 04, 2009 10:10 pm
by refresh
what are the demos and what are you applying to the scripts actor wise :shock:

Re: check points

PostPosted: Wed Mar 04, 2009 10:50 pm
by skydereign
That method refers to saving your last checkpoint closing your game, and playing it from that last checkpoint. Is that what you wanted?

This method is the checkpoint system, with a save/load addition. If the checkpoint is a flag, then
Player->Collision (Disable Repeat)->Script Editor
Code: Select all
checkpoint++;


This will mark how many checkpoints you have passed, note that if you are able to repeat checkpoints than you would want to do it in a similar fashion as this
Player->Collision (Disable Repeat)->Script Editor
Code: Select all
if (collide.cloneindex==checkpoint)
{
    checkpoint++;
}

This way ensures that checkpoint goes up only if it is the next checkpoint. The flaw would be if you skip a checkpoint... To fix that, you can use this method
Player->Collision (Disable Repeat)->Script Editor
Code: Select all
checkpoint=collide.cloneindex;

This now remembers whichever checkpoint you last hit.

Now when you need to move back to that checkpoint, let's say when you die, then you would need to create the actor in the correct spot. One way is to send an activation event to the checkpoint flags, and that will cause the right one to create your actor. I personally would create a die variable, and in the draw actor of the checkpoints, they have
Flag->DrawActor->Script Editor
Code: Select all
if (die==1 && cloneindex==checkpoint)
{
    //Create Actor
    die=0;
}

On the destroy actor, you would want to set die equal to zero, probably with a timer, otherwise the effect would be immediate. In most cases that is not preferred.

For the save/load, I would need to find a demo for you, but a good thing to read if you are ever wondering about a function's use
http://game-editor.com/docs/script_reference.htm
Just search for the saveVars and loadVars functions. They are pretty self explanatory, but you must make sure they are in a save group when creating the variable.


I changed the method from above, but both will work. Use whichever you feel is best. Not sure if this answered your question...