Discuss Scratch

thefloormat69
Scratcher
84 posts

Help with a 1 script game

Is there a way to set a chack point with 1 script so if you die you respawn there insted of at the start?
drmcw
Scratcher
1000+ posts

Help with a 1 script game

Don't see why not. You could have a variable called checkpoint that is set or unset and check that when you die.
CrystalStar-
Scratcher
100+ posts

Help with a 1 script game

Yeah.

To set a checkpoint, create 2 new variables - ‘checkpoint x’ and ‘checkpoint y’. Have them be reset to “none” whenever the green flag is pressed.

Then use…

set checkpoint x to (x position)
set checkpoint y to (y position)

…whenever you want to set a checkpoint.

Then, where-ever your script is for respawning, change it to…

if <not <checkpoint x = none>>
go to x: (checkpoint x) y: (checkpoint y)
else
go to x: y: - set these to the starting co-ordinates.

You might want to reset both of these variables to “none” whenever you enter a new level.

Edit: or use drmcw's method above if you don't want the player to actually ‘drop’ a checkpoint.

Last edited by CrystalStar- (Aug. 23, 2013 14:40:15)

Psiborg
Scratcher
500+ posts

Help with a 1 script game

Too late :)

Something like:

forever
set startx to 0
set starty to 0
repeat until lives = 0
go to startx starty
repeat until <lose life condition>
<main game code>
if <checkpoint condition>
set startx to checkpointx
set starty to checkpointy
/if
/repeat
/repeat
/forever

Last edited by Psiborg (Aug. 23, 2013 14:40:18)

Powered by DjangoBB