Discuss Scratch

millerjon
Scratcher
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
Scratcher
100+ posts

Sprite boundaries(certain sprites can only roam inside a certain area)

millerjon wrote:

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.
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:

barrier for the left(exemple: its a blue barrier):
whenclickedsetghosteffectto100

fish script:
whenclickedforeveriftouchingcolorblue?thenchangexbyminusspeedthefishisgoing
___________________________________________________________________________________
or only (still for left barrier) (fish):

whenclickedforeveriftouchingleft barrier?thenchangexbyminusspeedthefishisgoing
___________________________________________________________________________________
or something like (fish script) (for all sides still) (note you can change the value, not obligated 170):

whenclickedforeverifxposition>170thenchangexbyminusspeedthefishisgoingifxposition<-170thenchangexbyspeedthefishisgoingifyposition>170thenchangeybyminusspeedthefishisgoingup/downifyposition<-170thenchangeybyspeedthefishisgoingup/down

Last edited by Vicream_Creator (Feb. 17, 2018 15:05:59)

millerjon
Scratcher
17 posts

Sprite boundaries(certain sprites can only roam inside a certain area)

so what your saying i make a barrier
whenIreceivestart gotox:-85y:-16showsetsizeto35%foreverpointindirectionpickrandom0to36repeatuntiltouchingcolorblue?move1steps
millerjon
Scratcher
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
Scratcher
17 posts

Sprite boundaries(certain sprites can only roam inside a certain area)

also i forgot the ghost effect
Green_411
New Scratcher
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
Scratcher
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
Scratcher
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)

Powered by DjangoBB