Discuss Scratch

crazydoglady31
Scratcher
15 posts

How to I make a sprite glide around randomly?

I want to make it where a bunch of sprites are just floating around randomly. (like in the game slither) How can I make that script?
ELevell
Scratcher
100+ posts

How to I make a sprite glide around randomly?

Try something like this:

forever
glide (1) secs to x: (pick random (-240) to (240)) y: (pick random (180) to (-180))
end

Let me know if this helps!

Spelling is
chalanging
difucult
hard.
duckboycool
Scratcher
1000+ posts

How to I make a sprite glide around randomly?

What do you mean by floating around randomly. What I'm thinking of does not happen in slither.io.

If that's what you mean, you should also have a pick random .5 to 3 in the secs to make it more random.

Last edited by duckboycool (Jan. 27, 2017 01:48:38)


I used to be active on the forums, but I have mostly moved past Scratch. I still do check my Scratch messages, so if you'd like to talk to me, just pop a comment on my profile. My main project on Scratch was Cookie Clicker, but I've also recently made a project called Snake Snake, a game based off of Snake, but there are two snakes, and you can play either singleplayer or multiplayer.

DominoDragon1
Scratcher
1000+ posts

How to I make a sprite glide around randomly?

This is the same thing, but the sprite will always move the same speed, I think.

forever
set [x] to (pick random (-240) to (240))
set [y] to (pick random (-180) to (180))
glide ((Something) * ([sqrt] of (([square] of ((x) - (y))) + ([square] of ((x position) - (y position)))))) secs to x: (x) y: (y)
end
Last part was cut off, it should be:
y: y(the variable)
The something should be a number you play around with to get the speed you want.
Hope I helped!

Last edited by DominoDragon1 (Jan. 27, 2017 01:58:53)


There are 10 kinds of people in the world, those who know binary and those who don't. “And those who think they do but are still waiting on 8 more people.” (Sigton).
crazydoglady31
Scratcher
15 posts

How to I make a sprite glide around randomly?

Thank you! did it
ELevell
Scratcher
100+ posts

How to I make a sprite glide around randomly?

crazydoglady31 wrote:

Thank you! did it

Nice work! Which script did you use?

Spelling is
chalanging
difucult
hard.
crazydoglady31
Scratcher
15 posts

How to I make a sprite glide around randomly?


when green flag clicked
forever
go to x: (pick random () to (10)) y: ((pick random () to (10))
end

Last edited by crazydoglady31 (Jan. 27, 2017 18:26:40)

DominoDragon1
Scratcher
1000+ posts

How to I make a sprite glide around randomly?

crazydoglady31 wrote:

when green flag clicked
forever
go to x: (pick random () to (10)) y: ((pick random () to (10))
end
This would make the sprite move all over the place randomly, not gliding there.

There are 10 kinds of people in the world, those who know binary and those who don't. “And those who think they do but are still waiting on 8 more people.” (Sigton).
crazydoglady31
Scratcher
15 posts

How to I make a sprite glide around randomly?

i dont know for sure how to fix that but its ok
Bentton
Scratcher
53 posts

How to I make a sprite glide around randomly?

If you want it to bounce around, use this script:
when green flag clicked
point in direction (pick random (-90) to (270))
go to x: (0) y: (0)
set rotation style [don't rotate]
forever
move (10) steps
if on edge, bounce
end
Otherwise, If you want it to glide around do what ELevell said:

ELevell wrote:

Try something like this:

forever
glide (1) secs to x: (pick random (-240) to (240)) y: (pick random (180) to (-180))
end

Let me know if this helps!

This is Bob:
when green flag clicked
switch costume to [Expensive clothes v]
forever
make fun of [People without v] [Expensive clothes v]
end
Don't be like Bob. Don't judge people based on their clothing or shoes.
KoenigseggRS
Scratcher
2 posts

How to I make a sprite glide around randomly?

That helped
KoenigseggRS
Scratcher
2 posts

How to I make a sprite glide around randomly?

Bentton wrote:

If you want it to bounce around, use this script:
when green flag clicked
point in direction (pick random (-90) to (270))
go to x: (0) y: (0)
set rotation style [don't rotate]
forever
move (10) steps
if on edge, bounce
end
Otherwise, If you want it to glide around do what ELevell said:

ELevell wrote:

Try something like this:

forever
glide (1) secs to x: (pick random (-240) to (240)) y: (pick random (180) to (-180))
end

Let me know if this helps!
That helped.
C4-4life
Scratcher
3 posts

How to I make a sprite glide around randomly?

but what if your sprite starts at 0,0

Powered by DjangoBB

Standard | Mobile