Discuss Scratch

ethannilesarmstrong
Scratcher
11 posts

how to move randomly

i am making a pacman game and i cant get the ghosts to move randomly
so far ive got


when backdrop switches to [ v]
forever
point in direction ((pick random () to (10)) v)
move () steps
if <> then
<color [#e15b8c] is touching [#b02f6c] ?>
turn cw () degrees
turn ccw () degrees


else

end
end

Last edited by ethannilesarmstrong (Jan. 2, 2018 21:41:50)

ethannilesarmstrong
Scratcher
11 posts

how to move randomly

ethannilesarmstrong wrote:

i am making a pacman game and i cant get the ghosts to move randomly
so far ive got


when backdrop switches to [ v]
forever
point in direction ((pick random () to (10)) v)
move () steps
if <> then
<color [#e15b8c] is touching [#b02f6c] ?>
turn cw () degrees
turn ccw () degrees


else

end
end
sorry i dont know how to do this

Last edited by ethannilesarmstrong (Jan. 2, 2018 21:49:43)

ethannilesarmstrong
Scratcher
11 posts

how to move randomly

Your text to link here…
click tis to find the prob
ethannilesarmstrong
Scratcher
11 posts

how to move randomly

ethannilesarmstrong wrote:

Your text to link here…
click tis to find the prob
sorry wont work search untitled 2
asivi
Scratcher
1000+ posts

how to move randomly


ethannilesarmstrong wrote:

untitled 2
click tis to find the prob

Last edited by asivi (Jan. 2, 2018 22:21:01)

matthewparkerstas
Scratcher
65 posts

how to move randomly

when green flag clicked
forever
wait (how often they move) secs
glide (time it takes them to move) secs to x: (pick random (-200) to (200)) y: (pick random (-200) to (200))
end

It's free real estate

50th post on February 5th, 2018
ethannilesarmstrong
Scratcher
11 posts

how to move randomly

matthewparkerstas wrote:

when green flag clicked
forever
wait (how often they move) secs
glide (time it takes them to move) secs to x: (pick random (-200) to (200)) y: (pick random (-200) to (200))
end
wd ya mean
Foxy112345
Scratcher
100+ posts

how to move randomly

ethannilesarmstrong wrote:

matthewparkerstas wrote:

when green flag clicked
forever
wait (how often they move) secs
glide (time it takes them to move) secs to x: (pick random (-200) to (200)) y: (pick random (-200) to (200))
end
wd ya mean

He means:
when green flag clicked
forever
wait (1.2) secs
glide (2) secs to x: (pick random (-200) to (200)) y: (pick random (-200) to (200))
end

You can adjust the numbers to fit with your idea.

Last edited by Foxy112345 (Jan. 3, 2018 10:02:28)


Foxy112345 wrote:

If you want something to be believable, you must believe it yourself.
saodtheking
Scratcher
100+ posts

how to move randomly

when green flag clicked
forever
move (6) steps
if (touching [map v]) then
set [random v] to (pick random (1) to (2))
if ((random) = (1)) then
turn cw (90) degrees

else
turn cw (-90) degrees
end
end

this should work

Last edited by saodtheking (Jan. 3, 2018 11:21:31)


ethannilesarmstrong
Scratcher
11 posts

how to move randomly

Foxy112345 wrote:

ethannilesarmstrong wrote:

matthewparkerstas wrote:

when green flag clicked
forever
wait (how often they move) secs
glide (time it takes them to move) secs to x: (pick random (-200) to (200)) y: (pick random (-200) to (200))
end
wd ya mean

He means:
when green flag clicked
forever
wait (1.2) secs
glide (2) secs to x: (pick random (-200) to (200)) y: (pick random (-200) to (200))
end

You can adjust the numbers to fit with your idea.
well its also a maize
-ShadowOfThePast-
Scratcher
100+ posts

how to move randomly

ethannilesarmstrong wrote:

i am making a pacman game and i cant get the ghosts to move randomly
If you're making a pacman game, as in with a maze, you'd need to make it so that the ghosts can move around the maze correctly, following the paths and not going through walls or whatever. In that case, just having a pick random block wouldn't work.

I'm probably really overcomplicating this, but: you could make the maze tile-based, storing the location of each tile in a list. Then make it so that the ghosts can use the list to determine all the possible routes from its position in the list, and then pick one at random. However, it's much easier said than done.

NOTE: My main account is @-ShadowOfTheFuture-.
ethannilesarmstrong
Scratcher
11 posts

how to move randomly

-ShadowOfThePast- wrote:

ethannilesarmstrong wrote:

i am making a pacman game and i cant get the ghosts to move randomly
If you're making a pacman game, as in with a maze, you'd need to make it so that the ghosts can move around the maze correctly, following the paths and not going through walls or whatever. In that case, just having a pick random block wouldn't work.

I'm probably really overcomplicating this, but: you could make the maze tile-based, storing the location of each tile in a list. Then make it so that the ghosts can use the list to determine all the possible routes from its position in the list, and then pick one at random. However, it's much easier said than done.
thanks do show if you can
what i meant is can you show me
_______________________________________________________________________________________________

Your text to link here…

Last edited by ethannilesarmstrong (Jan. 13, 2018 01:35:29)

ethannilesarmstrong
Scratcher
11 posts

how to move randomly

saodtheking wrote:

when green flag clicked
forever
move (6) steps
if (touching [map v]) then
set [random v] to (pick random (1) to (2))
if ((random) = (1)) then
turn cw (90) degrees

else
turn cw (-90) degrees
end
end

this should work

wil work in a maize

Last edited by ethannilesarmstrong (Jan. 13, 2018 15:17:45)

Powered by DjangoBB

Standard | Mobile