Discuss Scratch

Tommy100
Scratcher
100+ posts

How do I make an enemy on a game that has a mind of its own? (sort of)

I'm making a game that is kind of like pac man. Except that you are not allowed to kill the enemies. And I was wondering how I make an enemy that kind of has a mind of its own. So it randomly goes around the maze. Except that I do not want it to go right through parts of the maze. I want it to go as it should so that when it goes around the maze is doesn't touch a wall. Please help me!
DudmasterUltra
Scratcher
100+ posts

How do I make an enemy on a game that has a mind of its own? (sort of)

You can use the random block to create random numbers, and the if statement to tell which path it will take. Pac-Man ai is a little tougher than regular since they have to not go through walls. Maybe you figure something out using glide blocks and random
CatScratchDeluxe
New Scratcher
11 posts

How do I make an enemy on a game that has a mind of its own? (sort of)

I'm pretty sure the enemies should have something like this;
whenclickedforeverglidepickrandomto10secstox:pickrandomto10y:pickrandomto10
Make something else to make it avoid the walls like
whenclickediftouchingcolor?then
The blank space should make it unable to go through the wall
Tommy100
Scratcher
100+ posts

How do I make an enemy on a game that has a mind of its own? (sort of)

DudmasterUltra wrote:

You can use the random block to create random numbers, and the if statement to tell which path it will take. Pac-Man ai is a little tougher than regular since they have to not go through walls. Maybe you figure something out using glide blocks and random
I tried that but the problem is that I want levels too. And the levels have different pathways… So it would take a LONG TIME to do that! Any other suggestions?
Tommy100
Scratcher
100+ posts

How do I make an enemy on a game that has a mind of its own? (sort of)

CatScratchDeluxe wrote:

I'm pretty sure the enemies should have something like this;
whenclickedforeverglidepickrandomto10secstox:pickrandomto10y:pickrandomto10
Make something else to make it avoid the walls like
whenclickediftouchingcolor?then
The blank space should make it unable to go through the wall
Thanks I will try that but I don't know if it will work. Everyone I'm still open for suggestions!
RichardStarbright
Scratcher
38 posts

How do I make an enemy on a game that has a mind of its own? (sort of)

See http://scratch.mit.edu/projects/23515861/ , it is a good example of a computer having a “mind of its own”
excelguru
Scratcher
1000+ posts

How do I make an enemy on a game that has a mind of its own? (sort of)

Maybe something like this:

Stepscreate this variablerepeatuntiltouchingcolorchangeyby5changeyby-5foreverIfx positionofplayer>xpositionSetstepsto5ElseSetstepsto-5repeatuntiltouchingcolorchangexbystepschangexby0-stepsIfy positionofplayer>ypositionSetstepsto5ElseSetstepsto-5repeatuntiltouchingcolorchangeybystepschangeyby0-steps
deck26
Scratcher
1000+ posts

How do I make an enemy on a game that has a mind of its own? (sort of)

That's the sort of thing I think a grid system is useful for. I did a tutorial here http://scratch.mit.edu/projects/47150778/
Harakou
Scratcher
1000+ posts

How do I make an enemy on a game that has a mind of its own? (sort of)

excelguru wrote:

Maybe something like this:

Stepscreate this variablerepeatuntiltouchingcolorchangeyby5changeyby-5foreverIfx positionofplayer>xpositionSetstepsto5ElseSetstepsto-5repeatuntiltouchingcolorchangexbystepschangexby0-stepsIfy positionofplayer>ypositionSetstepsto5ElseSetstepsto-5repeatuntiltouchingcolorchangeybystepschangeyby0-steps
Thanks, but this thread is over half a year old - please check the date before posting! Closing this, but if the thread owner wants this open again, they can just report it and ask.

Powered by DjangoBB