Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Help with a 1 script game
- 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?
Try my 1 script and 1 sprite game http://scratch.mit.edu/projectshttp:/
Also try my new beta side scoller game http://scratch.mit.edu/projects/12972745/
Also support my AE studio! http://scratch.mit.edu/studios/269420/projects/
- 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.
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
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)
Save the world from giant ants in a classic tower defense: Antfestation
Protect the Minions from the Purples in Minion Push
Collect treasure across the beautiful islands of Mylands
Guard your gold in The Hoard++
Remake of a classic arcade game: Descentipede
- Discussion Forums
- » Help with Scripts
- » Help with a 1 script game