Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » how to move randomly
- ethannilesarmstrong
- Scratcher
13 posts
how to move randomly
i am making a pacman game and i cant get the ghosts to move randomly
so far ive got
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
13 posts
how to move randomly
sorry i dont know how to do this 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:49:43)
- ethannilesarmstrong
- Scratcher
13 posts
how to move randomly
Your text to link here…
click tis to find the prob
click tis to find the prob
- ethannilesarmstrong
- Scratcher
13 posts
how to move randomly
sorry wont work search untitled 2 Your text to link here…
click tis to find the prob
- asivi
- Scratcher
1000+ posts
how to move randomly
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
13 posts
how to move randomly
wd ya meanwhen 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
- Foxy112345
- Scratcher
100+ posts
how to move randomly
wd ya meanwhen 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
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)
i left lol
- ethannilesarmstrong
- Scratcher
13 posts
how to move randomly
well its also a maizewd ya meanwhen 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
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.
- -ShadowOfThePast-
- Scratcher
100+ posts
how 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 am making a pacman game and i cant get the ghosts to move randomly
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.
Hello.
- ethannilesarmstrong
- Scratcher
13 posts
how to move randomly
thanks do show if you canIf 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 am making a pacman game and i cant get the ghosts to move randomly
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.
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
13 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
wil work in a maize
Last edited by ethannilesarmstrong (Jan. 13, 2018 15:17:45)
- Discussion Forums
- » Help with Scripts
- » how to move randomly