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

#1 2012-05-26 20:50:38

pjt4jc
Scratcher
Registered: 2012-01-20
Posts: 11

Enemies, Obstacles, and Firing Weapons

I'm getting ready to begin my third installment of the Monkey Ninja series. However, I'm having a great deal of trouble trying to get enemies to appear and walk about and creating a script to get the character to fire weapons. Can someone help me out?

Offline

 

#2 2012-05-26 22:06:13

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Enemies, Obstacles, and Firing Weapons

You could try out my Tanks game in my signature, it has some stuff like that in it.


Why are the secret organizations getting all the attention?  mad

Offline

 

#3 2012-05-27 00:25:35

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

Re: Enemies, Obstacles, and Firing Weapons

pjt4jc wrote:

I'm getting ready to begin my third installment of the Monkey Ninja series. However, I'm having a great deal of trouble trying to get enemies to appear and walk about

It sounds like you're trying to create some basic artificial intelligence for your enemies. There are many ways of approaching this, and because I don't know the structure of your program, I'll try to keep this pretty generic.

To get the enemy sprites to appear, you could set up a script in the stage like this:

when gf clicked
forever
if <(enemy)=[dead]>
wait <pick random (1) to (10)> secs //change this to whatever you want
broadcast [show enemy v]
Then in the enemy's scripts, add something like this:

when I receive [show enemy v]
show
do ai stuff
As for getting the enemies to walk around, you could use something as simple as this:

forever
point towards [main character v]
move (5) steps

pjt4jc wrote:

and creating a script to get the character to fire weapons.

For firing weapons, I would create a "bullet" sprite, and add a script like this:

When [space v] key pressed
show
go to [main character v]
point in direction ([direction v] of [main character v])
repeat until <<touching [edge v]?>or<touching [other enemies v]?>>
move (8) steps
Hope this answered your questions!  wink

Offline

 

#4 2012-05-27 16:08:46

BobThescratcher
Scratcher
Registered: 2011-08-02
Posts: 19

Re: Enemies, Obstacles, and Firing Weapons

Thanks

Offline

 

Board footer