Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Sprite boundaries(certain sprites can only roam inside a certain area)
- millerjon
-
17 posts
Sprite boundaries(certain sprites can only roam inside a certain area)
I am trying to make a game in which fish move around inside a fish tank and you have to keep them alive as long as possible. I need to make some kind of invisible boundaries for the fish but i cant think of anyway to do it. If anybody can help me thanks a bunch.
- Vicream_Creator
-
100+ posts
Sprite boundaries(certain sprites can only roam inside a certain area)
So that he has a limit to not trespass, like 10 feets away from each border? Welp there is more than one way to make this. First: make a barrier, and do this little script on: I am trying to make a game in which fish move around inside a fish tank and you have to keep them alive as long as possible. I need to make some kind of invisible boundaries for the fish but i cant think of anyway to do it. If anybody can help me thanks a bunch.
barrier for the left(exemple: its a blue barrier):
fish script:
___________________________________________________________________________________
or only (still for left barrier) (fish):
___________________________________________________________________________________
or something like (fish script) (for all sides still) (note you can change the value, not obligated 170):
Last edited by Vicream_Creator (Feb. 17, 2018 15:05:59)
- millerjon
-
17 posts
Sprite boundaries(certain sprites can only roam inside a certain area)
so what your saying i make a barrier
- millerjon
-
17 posts
Sprite boundaries(certain sprites can only roam inside a certain area)
idk what the red block the pick random is its not atually in there but whats happening is the fish are just swimming.
- millerjon
-
17 posts
Sprite boundaries(certain sprites can only roam inside a certain area)
also i forgot the ghost effect
- Green_411
-
1 post
Sprite boundaries(certain sprites can only roam inside a certain area)
Maybe you should just make the ocean fish tank and rotate can work for them swimming around…
- millerjon
-
17 posts
Sprite boundaries(certain sprites can only roam inside a certain area)
Well that makes sense, but i had an idea where that works. Basically it checks if the sprite's cordinates in each direction arent in an area, if not, it moves back 10 steps, then starts the script again.
- Game_Talk12
-
5 posts
Sprite boundaries(certain sprites can only roam inside a certain area)
I have one for you
Use one sprite for a barrier and make two Variables (for one sprite only) and name them: OldX, and OldY.
Do a forever loop and inside set OldX to xposition and OldY to yposition
Use “When Touching -The barrier sprite you chose- go to (drag the X variable in the X spot and the Y in the Y spot)” and that should work
Hope this helped (I know I'm really late to this lol)
Use one sprite for a barrier and make two Variables (for one sprite only) and name them: OldX, and OldY.
Do a forever loop and inside set OldX to xposition and OldY to yposition
Use “When Touching -The barrier sprite you chose- go to (drag the X variable in the X spot and the Y in the Y spot)” and that should work
Hope this helped (I know I'm really late to this lol)
- Discussion Forums
- » Help with Scripts
-
» Sprite boundaries(certain sprites can only roam inside a certain area)