Discuss Scratch

Dumbation
Scratcher
19 posts

Randomized Movement

I'm Making A Fnaf Based Game And Need Help For A Script For The Characters To Randomly Move.

I make games. I'm probably here because I need help. Pls Help
Mint-Kins
Scratcher
76 posts

Randomized Movement

when green flag clicked
go to [random position v]
or
when green flag clicked
glide (any value) secs to random position
correct me if im wrong .^.

“Sayu, Shuumatsuban, at your disposal! Whew, but if you don't need me right now, I'm gonna grab some sleep. I need the extra room to grow into.”
Dumbation
Scratcher
19 posts

Randomized Movement

Mint-Kins wrote:

when green flag clicked
go to [random position v]
or
when green flag clicked
glide (any value) secs to random position
correct me if im wrong .^.

So What I Need Is For The Characters To Randomly Move To A Different Spot And They Have Assigned Spots To Go But I Can't Figure Out How To Move Them To That Spot Without Bunches Of Costumes But Then I Would Have To Make A Costume For Every Possible Combination Of Characters In Different Spots, So I'm Thinking That I Use Dots As The Place They Are And Those Are Sprites And They Randomly Move To A Spot They Are Assigned But The Problem Is Is That I Can't Figure Out How To Make The Movement Random.

I make games. I'm probably here because I need help. Pls Help
Vaibhs11
Scratcher
1000+ posts

Randomized Movement

Reporting to be moved to HWS
Do you mean clones?

Edit: wait what the- wasn't this in TIMAC?

Last edited by Vaibhs11 (Sept. 29, 2021 15:13:20)

marti11111marti
Scratcher
14 posts

Randomized Movement

move (pick random (1) to (20)) steps
or
glide (1) secs to random position

Last edited by marti11111marti (Sept. 29, 2021 18:43:15)

szogye
Scratcher
83 posts

Randomized Movement

So I think I know what you mean. You want to have specific spots for them to go to but you want it to be randomized?

when flag clicked
go to x:(pick random (1) to (lenth of [random x v])) y:(pick random (1) to (lenth of [random y v]))

So basically if you wanted to do this would make 2 lists, one for x and one for y. So let's say one point is X=5 and Y=1 you would put 5 in the random x list and 1 in the random y list. Sorry if this is confusing, but let me know if you need any help.

I've been on Scratch for around 7 years, but I'm not as active as I used to be because of school, and other things.

when I start as a clone
create clone of [myself v]
delete this clone
‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ↑
Cool little piece of code. T̴̨̈̓̒r̵̠͂̓̚ȳ̸̥̯̣̿̏ ̵͎̼͈͉͗̊͝ị̷̼̌̒̕ͅt̵̯̮̘̭̽͛͂.̷̡̺̪̐͊̚[
szogye
Scratcher
83 posts

Randomized Movement

szogye wrote:

So I think I know what you mean. You want to have specific spots for them to go to but you want it to be randomized?

when flag clicked
go to x:(pick random (1) to (lenth of [random x v])) y:(pick random (1) to (lenth of [random y v]))

So basically if you wanted to do this would make 2 lists, one for x and one for y. So let's say one point is X=5 and Y=1 you would put 5 in the random x list and 1 in the random y list. Sorry if this is confusing, but let me know if you need any help.
Also, I think there would be a more efficient way of doing this but it would require more code.

I've been on Scratch for around 7 years, but I'm not as active as I used to be because of school, and other things.

when I start as a clone
create clone of [myself v]
delete this clone
‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ↑
Cool little piece of code. T̴̨̈̓̒r̵̠͂̓̚ȳ̸̥̯̣̿̏ ̵͎̼͈͉͗̊͝ị̷̼̌̒̕ͅt̵̯̮̘̭̽͛͂.̷̡̺̪̐͊̚[
classy1M
Scratcher
7 posts

Randomized Movement

Ok here’s a few ways to do it.

Code 1:

For Code 1 there will be any event block and when the event happens, the character will point in a random direction. Then another part will make it move.

Random Direction Code:

when I receive [Event v]
set rotation style [Left-Right v]
point in direction ((pick random (-179) to (180)) v)

Move Code:

when green flag clicked
repeat until <>
move () steps
end

Code 2:

Code 2 will start by pointing in a random direction and will move while randomly turning.

The Code:

when green flag clicked
point in direction ((pick random (-179) to (180)) v)
set rotation style [Left-Right v]
repeat until <>
move () steps
turn cw (pick random (-5) to (10)) degrees
if on edge, bounce
wait (0.01) secs
end

Warning: I did not test these codes, but I think they work. Thanks!

Last edited by classy1M (Sept. 29, 2021 23:25:25)


Keep it Classy
Nezon
Scratcher
1000+ posts

Randomized Movement

I don't think you can make FNAF games. However, that is my thinking. Please ask the QaS forum about making a FNAF project.

This is my signature (it goes automatically under every post I make)! Here is a bit of advice on foruming, by the way. Don't do SAND. SAND means four words.
SAND means Spam, Advertising, Necroposting, and Derailing.
Spam is when a irrelevant message is sent to many places. Wiki Article: Spam
Advertising is when you promote your studios and projects. Wiki Article: Advertising
Necroposting is when you post on a old topic. It distracts other helpers! Wiki Article: Necroposting
Derailing is when you post something that is irrelevant to the topic, like minimodding. It is called thread hijacking. Wiki Article: Derailing(Derailing idea comes from this guy),
in the process of leaving scratch.
bob has been hidden again :(

Powered by DjangoBB