Discuss Scratch

Khartas
New to Scratch
2 posts

How to make sprites move randomly in a maze?

Hello it is me again and today I would like to ask the question that how can I make sprites move randomly in a maze so that they will not cross the walls. My attempts to do that have failed by the sprites starting to shake and move strangely in all directions, even though the idea would be that they move only in the ways that the maze go. Also the sprites cross the walls of the maze be shaking over them. If it is any help the randomly moving sprites should move like the ghosts in pacman as the maze will be similar and also the coming game will be similar to pacman but with little math flavor. I would also like to know what are the best ways to make the walls of the maze uncrossable.
Thanks for your answers.
Photoguy77
Scratcher
100+ posts

How to make sprites move randomly in a maze?

Well have it point in a random direction (you must use a circle) and repeat until touching maze it will move 1 step .

-Photoguy77

“Without enjoying, one will never truly learn” ~Flome

“Finding happiness starts in you” ~ProdigyZeta7

scubajerry
Scratcher
1000+ posts

How to make sprites move randomly in a maze?

It is best if costumes are circles, or at least symmetrical. It is critical that they be exactly centered.

http://scratch.mit.edu/projects/14045823/

Last edited by scubajerry (Nov. 8, 2013 00:00:32)

dabus1102
Scratcher
63 posts

How to make sprites move randomly in a maze?

when green flag clicked
forever

point in direction (pick random (0) to (360))
move (pick random (5) to (10)) steps
end

Last edited by dabus1102 (April 2, 2015 14:10:30)


when [y v] key pressed :: motion
move (8) steps :: pen
if on edge, bounce :: control
165555
Scratcher
31 posts

How to make sprites move randomly in a maze?

Yes dabus1102 is correct.
wkelly42
Scratcher
100+ posts

How to make sprites move randomly in a maze?

dabus1102 wrote:

when green flag clicked
forever

point in direction (pick random (0) to (360))
move (pick random (5) to (10)) steps
end
You will also need something to detect collision with the maze walls, and tell the sprite to change direction when it hits the walls.

Last edited by wkelly42 (April 3, 2015 17:21:16)


My Retro Arcade:
COMPLETED: Frogger, Missile Command, Computer Space.
IN DEVELOPMENT: Barnstorming, Time Pilot, Defender, River Raid, Karateka
dabus1102
Scratcher
63 posts

How to make sprites move randomly in a maze?

wkelly42 wrote:

dabus1102 wrote:

when green flag clicked
forever

point in direction (pick random (0) to (360))
move (pick random (5) to (10)) steps
end
You will also need something to detect collision with the maze walls, and tell the sprite to change direction when it hits the walls.
when green flag clicked
forever

point in direction (pick random (1) to (360)
move (pick random (5) to (10)) steps
if <touching color [#000000] ?> then
turn ccw (180) degrees

end

end

when [y v] key pressed :: motion
move (8) steps :: pen
if on edge, bounce :: control
aarushm22
Scratcher
100+ posts

How to make sprites move randomly in a maze?

when green flag clicked
forever

point in direction ((pick random (1) to (200)) v)
if <color [#00ff00] is touching [#000000] ?> then
move (3) steps

end

end

when you are on scratch :: events hat 
have fun ::sensing
This song is awesome:
This is the singing part of a song and the insrumental song.
Invisible_Factory
Scratcher
500+ posts

How to make sprites move randomly in a maze?

aarushm22 wrote:

when green flag clicked
forever

point in direction ((pick random (1) to (200)) v)
if <color [#00ff00] is touching [#000000] ?> then
move (3) steps

end

end
Please don't necropost, the topic is over 2 years old.

Currently, I have ~860 posts.
I am a scratcher who used to be really active on the forums 5 or 6 years ago, I basically quit scratch since then but I still check out the website from time to time. Do not expect asap replies because scratch is really at the back of my head

chelseablues
Scratcher
3 posts

How to make sprites move randomly in a maze?

()
BenCraft123
Scratcher
2 posts

How to make sprites move randomly in a maze?

asivi
Scratcher
1000+ posts

How to make sprites move randomly in a maze?

BenCraft123 wrote:

You have started badly in your first post at the Scratch site. Yours is considered SPAM.
PitSkinner
New to Scratch
32 posts

How to make sprites move randomly in a maze?

I am making a game with a similar maze concept. The character will walk around the graveyard rooms looking for 8 roses. I am having trouble trying to get each rose to appear in the right room at the right time and not have 2 roses visible at once. I am also having trouble getting the enemy to follow the player around the graves one a rose is collected. NEED HELP URGENTLY!

Last edited by PitSkinner (April 7, 2016 09:34:18)

asivi
Scratcher
1000+ posts

How to make sprites move randomly in a maze?

PitSkinner wrote:

I am making a game with a similar maze concept. The character will walk around the graveyard rooms looking for 8 roses. I am having trouble trying to get each rose to appear in the right room at the right time and not have 2 roses visible at once. I am also having trouble getting the enemy to follow the player around the graves one a rose is collected. NEED HELP URGENTLY!
Make your own topic instead of highjack another scratcher's topic, it's better for you and the owner of this.
PitSkinner
New to Scratch
32 posts

How to make sprites move randomly in a maze?

My internet didn't let me so i compromised.

Powered by DjangoBB