Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Help With Tron Game v3
- WILLPR19_
-
36 posts
Help With Tron Game v3
please ca someone show me how can you make a sprite follow a sprite and move only in straight lines
thanks
thanks
Last edited by WILLPR19_ (June 25, 2020 12:50:31)
- RL1123
-
1000+ posts
Help With Tron Game v3
Sprite following sprite:
forever
go to [sprite v]
end
- qucchia
-
100+ posts
Help With Tron Game v3
I suppose that by “straight lines” you mean it can only move left, right, up and down. Here's a simple example of a script that will follow a sprite (in this case it's called Sprite1).
when green flag clicked
forever
repeat until <(x position) > ([x position v] of [Sprite1 v])> // move right
change x by (10)
end
repeat until <(x position) < ([x position v] of [Sprite1 v])> // move left
change x by (-10)
end
repeat until <(y position) > ([y position v] of [Sprite1 v])> // move up
change y by (10)
end
repeat until <(y position) < ([y position v] of [Sprite1 v])> // move down
change y by (-10)
end
end
- Wyan100
-
1000+ posts
Help With Tron Game v3
Sprite following sprite:forever
go to [sprite v]
end
If you do that then it will just stick to whatever it's following. If you want it to actually follow the sprite then you should use glide blocks.
More like this:
forever
glide (1) secs to (character v) :: motion
end
- Discussion Forums
- » Help with Scripts
-
» Help With Tron Game v3