Discuss Scratch

elcooler
Scratcher
24 posts

Snake kills itself when green flag click :(

See the problem at the Snaaaaaake project : https://scratch.mit.edu/projects/169511227/#editor:|

when green flag clicked
turn cw (15) degrees
broadcast [spin v]

when I receive [spin v]
turn cw (15) degrees
broadcast [spin v]
stop [only this script :) v]

Infinite spin script without forever block
Lifeoftheparty29
Scratcher
17 posts

Snake kills itself when green flag click :(

It's the “Body” sprite. It automatically goes to the snake head, and kills it.

when I receive [Post End v]
say (Signature)
elcooler
Scratcher
24 posts

Snake kills itself when green flag click :(

but how do I make the Body clones make a trail behind the Head sprite?
when green flag clicked
if <> then
<[reply] contains [correct answer] ?>
broadcast [ yay!!]


else
wait until <><(Answer) = [correct]>
end

Last edited by elcooler (July 22, 2017 20:25:19)


when green flag clicked
turn cw (15) degrees
broadcast [spin v]

when I receive [spin v]
turn cw (15) degrees
broadcast [spin v]
stop [only this script :) v]

Infinite spin script without forever block
asivi
Scratcher
1000+ posts

Snake kills itself when green flag click :(

Perhaps movig the head forward and sitting in its previous place a body segment.
asivi
Scratcher
1000+ posts

Snake kills itself when green flag click :(

Consider the stamp feature.
lolad
Scratcher
54 posts

Snake kills itself when green flag click :(

Try this. Make a list called something like ‘SnakePosX’, and ‘SnakePosY’, then this script in the body:

when gf clicked
delete [all v] of [SnakePosX v]
delete [all v] of [SnakePosY v]
forever
add ([x position v] of [head v]) to [SnakePosX v]
add ([y position v] of [head v]) to [SnakePosY v]
end

when gf clicked
hide
clear
go to x: (-240) y: (240)
set [counter v] to (0)
wait (3) secs
forever
change [counter v] by (1)
go to x: (item (counter) of [SnakePosX v]) y: (item (counter) of [SnakePosY v])
stamp
end

Hope you found this useful/interesting/funny

wake up::hat
do scratch::variables
and scratch::control
and scratch::operators
and scratch::motion
elcooler
Scratcher
24 posts

Snake kills itself when green flag click :(

when I receive [try that script]
set [ answer] to [no]
broadcast [ didn't work :(]

when green flag clicked
turn cw (15) degrees
broadcast [spin v]

when I receive [spin v]
turn cw (15) degrees
broadcast [spin v]
stop [only this script :) v]

Infinite spin script without forever block
Uniquename1
Scratcher
100+ posts

Snake kills itself when green flag click :(

Here's what I did. The body was touching the head immediately and there's only 1 head. So I moved the touching test into the body and changed it to check for color of head. That wasn't enough though so I made it wait 1 or 2 seconds before testing if it touches the head. I disconnected some unnecessary stuff and things with how it used to go.

I made the body just clone itself and wait .01 seconds before cloning again. Then I also made the body go to head, show, wait 5 seconds then delete itself. Length of time here determines how long you want it to get unless you want it to always grow then don't delete any body segments. Think thats all i did. I also added a wait.05 sec before it stops all to give another script time to say ouch. Messy, I pushed a bunch to the side and was working with what was already there. Could be simplified and condensed I'm sure.

https://scratch.mit.edu/projects/169647183/#player

Don't have the body forever go to head. Then it'll always be under the head. Just go to the head when it's first made then it can stay in that spot until it delete itself.

Last edited by Uniquename1 (July 24, 2017 19:33:25)


Try my games.
Scratch Sprite Club VI Soccer
Star Fighter Shooting
Space Marines: Boarding Party Strategy
Lion Runner Running/ Platformer
scubajerry
Scratcher
1000+ posts

Snake kills itself when green flag click :(

Powered by DjangoBB