Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » I need help with my snake game idk how to explain my problem in title
- starlightsparker
-
1000+ posts
I need help with my snake game idk how to explain my problem in title
So I madea snake game, and I want the game to end when it touches itself, like in the real snake xenia. Is it possible?
- starlightsparker
-
1000+ posts
I need help with my snake game idk how to explain my problem in title
Link to game https://scratch.mit.edu/projects/900351212
- existentialcrisises
-
100+ posts
I need help with my snake game idk how to explain my problem in title
I ran some tests in scratch, and I think there's a way to do it. You can set the “head” costume of the snake to be a slightly different colour, so your clones can sense whether it is touching the head with this:
But then the clone right at the back of the “head” will be touching them at all times, so you would automatically have a game over. So you need a variable to track if the clones are currently at the back of the head.
Then, you can do something like this:
But then the clone right at the back of the “head” will be touching them at all times, so you would automatically have a game over. So you need a variable to track if the clones are currently at the back of the head.
Then, you can do something like this:
Last edited by existentialcrisises (Sept. 30, 2023 12:04:42)
- starlightsparker
-
1000+ posts
I need help with my snake game idk how to explain my problem in title
wouldn’t that stop all scripts? The stop block?
- starlightsparker
-
1000+ posts
I need help with my snake game idk how to explain my problem in title
Actually nvm, but how do I code the variable?
- cookieclickerer33
-
1000+ posts
I need help with my snake game idk how to explain my problem in title
isnt that the point????? wouldn’t that stop all scripts? The stop block?
- starlightsparker
-
1000+ posts
I need help with my snake game idk how to explain my problem in title
I got confused, I said “nvm” later.
- existentialcrisises
-
100+ posts
I need help with my snake game idk how to explain my problem in title
Actually nvm, but how do I code the variable?
When a clone of the snake first spawns, it will be directly behind the head of the snake.
So, if the snake has not spawned any more clones after spawning a particular clone, that clone will be behind the head of the snake.
My suggestion would be to use clone IDs so that the clones know if the snake has spawned any more clones after spawning them. For example:
- Discussion Forums
- » Help with Scripts
-
» I need help with my snake game idk how to explain my problem in title