This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-03-20 22:07:21

Shin23
Scratcher
Registered: 2011-01-30
Posts: 100+

Enemies???

How do you make enemies that are actually good? I mean enemies that fight back and stuff, and can make simple decisions like which dirrection to go to avoid things and stuff. Thanks


http://scratch.mit.edu/static/projects/Shin23/1957329_med.png New Super Mario Bros. Scratch! (beta)
PSN: shauthegreat23

Offline

 

#2 2011-03-20 22:15:03

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Enemies???

Well, this would involve a very complicated type of programming called Artificial Intelligence, or AI. It's difficult to explain, because it varies for each place in which it's used, but you'd have to go through what decisions YOU would make in certain circumstances, and program the project to do the same thing... Go where your heart tells you!

Offline

 

#3 2011-03-20 23:21:41

silvershine
Scratcher
Registered: 2010-11-21
Posts: 500+

Re: Enemies???

What you want to do is complex, so I'll show you a few lines of code you could use.

This line of code would make the enemy point towards the user, and follow it. You can change the speed it follows the user.
[blocks]
<when green flag clicked>
<forever>
<point towards( user
<move( speed )steps>
[/blocks]

If the enemy was trying to avoid the user, you could do this:
[blocks]
<when green flag clicked>
<forever>
<point towards( user
<turn cw( 180 )degrees>
<move( speed )steps>
[/blocks]
*Note: this script will probably only work online, or in full-screen more

You could use similar scripts for bullets too.

Did that answer your question?  big_smile

Offline

 

#4 2011-03-21 16:14:30

Shin23
Scratcher
Registered: 2011-01-30
Posts: 100+

Re: Enemies???

Thanks it did help alot!


http://scratch.mit.edu/static/projects/Shin23/1957329_med.png New Super Mario Bros. Scratch! (beta)
PSN: shauthegreat23

Offline

 

Board footer