Discuss Scratch

spritex1000
New Scratcher
1 post

In a 'maze' game, how do you deduct points every time a sprite retraces its steps?

I'm making a 2 player maze game in Scratch. Basically, there's a complicated maze and whoever makes it to the end first wins. However, I want to make it so that every time a player were to retrace his/her steps (i.e. revisit the same coordinates he/she has already passed), points would be deducted from that player's score. It's like a penalty for the player going the wrong way or trying every possible path, since that would eventually lead them easily to the finish. What script would I use in order to do this? How do I attempt to go about this? I am using arrow keys, by the way. I appreciate the help! Thank you!
drmcw
Scratcher
1000+ posts

In a 'maze' game, how do you deduct points every time a sprite retraces its steps?

You could use a variable to store which direction they are going and whenever they go in the opposite direction then deduct a point.

e.g.
if key up arrow pressed then
if stored direction = down then
change score by -1
set stored direction to up

Last edited by drmcw (July 15, 2013 07:23:07)

armique
New Scratcher
39 posts

In a 'maze' game, how do you deduct points every time a sprite retraces its steps?

Other possibility is to leave little signs (as in the fairy tale, little pieces of bread) so, if you trace back, when touching signs points will be deducted.
Signs can be seen or not, setting ghost effect to 100.
Alex332122
Scratcher
7 posts

In a 'maze' game, how do you deduct points every time a sprite retraces its steps?

You can use lists to store the x-y values of the path, then have it so that if the sprite is within ~half the sprite's diameter of one of the x-y values stored in the lists, it deducts a point.
ritzbitz69
New Scratcher
1 post

In a 'maze' game, how do you deduct points every time a sprite retraces its steps?

So im making a maze game also, for some reason my sprite im using to give the player points doesnt switch costumes when it gets touched, it also adds alot more points then just one.
PJWog
Scratcher
7 posts

In a 'maze' game, how do you deduct points every time a sprite retraces its steps?

ritzbitz69 wrote:

So im making a maze game also, for some reason my sprite im using to give the player points doesnt switch costumes when it gets touched, it also adds alot more points then just one.

what script are you using?

Powered by DjangoBB