Can't end game when timer runs out

Hello. Can someone help me? This game should end when you get all five vampires. It doesn’t, and I can’t figure out why. Thanks.

2 Likes

Hi @tdrev, the problem occurs because the run parralel block runs everything inside of it once at the same time; So you end up checking if the played has score 5 at the very start of the game and then never again. It can be fixed by checking if the player has a score of 5 whenever he hits a vampire.

Try to avoid “run parralel” blocks as much as possible; Most things can be achieved by having the code run in an orginized structure; For “forever loops” like the ones you use for movement its best to use the “run seperately” block. It will run the code inside of it while also continueing with the code that comes after it right away. Parralel blocks create messy code and strange behaviour.

Another tip is try to use functions, they are incredibely usefull! Basically whenever you write the same (or very similar) code twice, instead write a function for it (done in the red function tab by selecting “create function”). I’ve done it here for you to make a single function create all of the movement for the vampires and rabbits, instead of having around 20 lines of code, the same is now achieved in 8. Also to make a vampire or rabbit move all you now need to add is the function block!

Good luck with the game!

1 Like

Wow, thanks very much for your help!

2 Likes

I put up the new version, and gave you a shoutout in the description. Thanks again.

2 Likes