Page 1 of 2

Tutorial: Making Checkpoints

PostPosted: Sun Jul 18, 2010 7:27 pm
by Bee-Ant
Hi newbies... :D
Well, I was told to make this tutorial..I'm not a good tutor anyway, but I'll try...


The System
The system is you will save your current location, defined by the x and y axis into variables, then you can save that variables into file. For example your save file will be "data.sav". In this system, you have Actors called "Player" as your main player, and "Checkpoint" as the checkpoint actor. Well, the you can use some flag sprite as the checkpoint actor.

Requirements
The requirement is only 2 variables. "PosX" - to define the x position, and "PosY" to define the y position. To make the variable, go to the Script Editor or Global code, then click "Variables" button bellow the window.
Image
You need to make the Save group in order to save them into file.

The Script
Here's the scripting step...
1. First, we want to save the current location when the Player colliding with the Checkpoint flag. So, we need to put this code on...
Player -> Collision -> Anyside of Checkpoint -> Script Editor
:
Code: Select all
PosX = x; //store the x position
PosY = y; //store the y position
saveVars("data.sav", "data"); //save the data into file "data.sav"

2. Then, we want if the player die, he will load his latest checkpoint location. In this case, the Player dying with DestroyActor, so on...
Player -> Destroy Actor -> Script Editor :
Code: Select all
CreateActor("Player", "PlayerAnimation", "(none)", "(none)", PosX, PosY, true); //create player to the latest checkpoint location
view.x=PosX-320; //set the view x position
view.y=PosY-240; //set the view y position

We need to set the view position in order for the camera will follow the Player.
3. The last is, when next time we play the game again, and want to load the latest checkpoint... So, on...
Player -> Create Actor -> Script Editor :
Code: Select all
loadVars("data.sav", "data"); //load your saved data from file
x=PosX; //set the x position
y=PosY; //set the y position
view.x=PosX-320; //set the view x position
view.y=PosY-240; //set the view y position


Please Note
Whenever we change the Player's location, don't forget to move the view's location as well. Or else, the camera won't follow you.

Hope helps, and thanks :D

Re: Tutorial: Making Checkpoints

PostPosted: Mon Jul 19, 2010 2:42 am
by Hblade
I added this to the Tutorials page


http://game-editor.com/Tutorials

Re: Tutorial: Making Checkpoints

PostPosted: Mon Jul 19, 2010 4:05 am
by Bee-Ant
Nice, thanks :D

Re: Tutorial: Making Checkpoints

PostPosted: Mon Jul 19, 2010 4:37 am
by krenisis
Good job bee-ant!! Now when anybody asks you , you dont have to retype same code over. Now just put the link to your tutorial and your set. Plus it will help Makslane sell more and make more improvements because Game Editor has best support staff of any IDE.

Re: Tutorial: Making Checkpoints

PostPosted: Sat Aug 28, 2010 7:55 pm
by JLx14
thanks it works but i cant make the camera view follow the player after he dies. it just stays where the checkpoint is.

Re: Tutorial: Making Checkpoints

PostPosted: Sat Aug 28, 2010 9:58 pm
by DBGames
very nice tutorial, however... your images look weird... :| whats up with that?

Re: Tutorial: Making Checkpoints

PostPosted: Sat Aug 28, 2010 10:00 pm
by Bee-Ant
JLx14 wrote:thanks it works but i cant make the camera view follow the player after he dies. it just stays where the checkpoint is.

If you follow all the instruction, you should be OK...
DBGames wrote:very nice tutorial, however... your images look weird... :| whats up with that?

I used 256 color since GE won't allow me to upload big image.

Re: Tutorial: Making Checkpoints

PostPosted: Sat Aug 28, 2010 10:08 pm
by DBGames
really? well, i tryed running my ge in 256 color ind it crashed immediatly... :(

on a side not, does this stupid java pop up P.O any one? we need to tell mak to change that back N O W.

Re: Tutorial: Making Checkpoints

PostPosted: Sat Aug 28, 2010 11:08 pm
by NightOfHorror
This maybe can help on my game, more like everybody's game(by the way it is called THE CHALLENGE and I know some of you might be interested, like bee-ant will probaly want to be the lead character designer) so thanks. :D

Re: Tutorial: Making Checkpoints

PostPosted: Sun Aug 29, 2010 10:01 am
by Bee-Ant
Bee-Ant wrote:I used 256 color since GE won't allow me to upload big image.

I mean GE forum, sorry...
DBGames wrote:on a side not, does this stupid java pop up P.O any one? we need to tell mak to change that back N O W.

I have asked Makslane before, but he didn't hear me...
It seems I need more vote on this matter

Re: Tutorial: Making Checkpoints

PostPosted: Sun Aug 29, 2010 6:13 pm
by JLx14
I followed everything, its just the last part where you say "don't forget to move the view's location as well. Or else, the camera won't follow you." I'm not sure what you mean by that. Im sorry im new to game-editor i just started using it 3 days ago

Re: Tutorial: Making Checkpoints

PostPosted: Mon Aug 30, 2010 3:20 am
by Bee-Ant
JLx14 wrote:I followed everything, its just the last part where you say "don't forget to move the view's location as well. Or else, the camera won't follow you." I'm not sure what you mean by that. Im sorry im new to game-editor i just started using it 3 days ago

Oh, it's just a warning...
Actually it has done by this code :
Code: Select all
view.x=PosX-320; //set the view x position
view.y=PosY-240; //set the view y position

Well, logically, after your player get Destroyed, then you Create a new player...
Put that code on Player -> Create Actor
I'm so sure there's something you missed :s

Re: Tutorial: Making Checkpoints

PostPosted: Fri Dec 24, 2010 10:13 am
by mog440
I followed this instructions and it didnt work when I went to game mode, but once I exited game mode, and went to game mode again,I started in the saved position( the checkpoint position) can you help?
And i presume I have to also destroy the checkpoint actor as I can collide more then once and create many players?

Re: Tutorial: Making Checkpoints

PostPosted: Fri Dec 24, 2010 4:36 pm
by Bee-Ant
In this tutorial, you will start from the checkpoint location when the player has died before.
"CreateActor() when colliding the checkpoint"?? I believe I didn't post this sentence on the first post.
When player collides the checkpoint, you just need to set the PosX and PosY values depend on the player'r X and y

Re: Tutorial: Making Checkpoints

PostPosted: Mon Jun 27, 2011 3:39 pm
by Pyathus
i cannot seem to get the view to follow the actor after I get killed and load at the nearest checkpoint. and the view also gets affected depending on what side (left/right/top) my character hits the enemy.