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

#1 2008-09-22 14:45:17

LoganClark
Scratcher
Registered: 2008-09-22
Posts: 1

AI's and Shooting.

Hello,
I am trying to make a game where if you click the mouse button, it fires a bullet to where the Mouse Pointer was when it got clicked. Also I'm making AI's that fire at the Hero, and I need help on that to. Please message me back soon.
                                                                      Thanks,
                                                                              Logan

Offline

 

#2 2008-09-22 14:50:50

TheCatAndTheBanana
Scratcher
Registered: 2008-03-21
Posts: 1000+

Re: AI's and Shooting.

shooting:

gun/shooter

<when green flag clicked>
<forever if><mouse down?>
<broadcast[ whatever you want  ]and wait>
<end>


<when green flag clicked>
<forever>
<point towards( mouse

<when I receive[ what you broadcasted
<repeat until> <touching[ edge/ enermy
<move( 2 )steps>

i hope it helps.

Last edited by TheCatAndTheBanana (2008-09-22 14:52:10)


My Newest Project!
Ceta? wat r u doin? CETA! STAHP!

Offline

 

#3 2008-09-22 22:06:44

SeanCanoodle
Scratcher
Registered: 2008-06-20
Posts: 100+

Re: AI's and Shooting.

My Mini Tanks AI is a pretty good example of an AI that shoots back. Build whatever AI for the enemy (I don't know what type of game you're making) then add a sprite called Line of Sight. Have it hide constantly shoot at the character, if it hits a wall, set the variable InSight to 0, if it hits the character make it 1. As long as it equals 1 make the AI shoot whatever projectile you want at the character. If the AI is too powerful, add a delay to each shot so it aims, waits, then shoots.

You're probably really confused. You can ignore the player sprites and other AI sensors if you're just looking for the line of sight AI.
Mini Tanks AI

Offline

 

#4 2008-09-23 09:00:01

yambanshee
Scratcher
Registered: 2007-11-06
Posts: 500+

Re: AI's and Shooting.

<touching[

SeanCanoodle wrote:

My Mini Tanks AI is a pretty good example of an AI that shoots back. Build whatever AI for the enemy (I don't know what type of game you're making) then add a sprite called Line of Sight. Have it hide constantly shoot at the character, if it hits a wall, set the variable InSight to 0, if it hits the character make it 1. As long as it equals 1 make the AI shoot whatever projectile you want at the character. If the AI is too powerful, add a delay to each shot so it aims, waits, then shoots.

You're probably really confused. You can ignore the player sprites and other AI sensors if you're just looking for the line of sight AI.
Mini Tanks AI

hmm, that is quite clever actually! I might use it in a shooting program sometime

As for firing at the mouse [blocks]
<when green flag clicked>
<forever>
   <if><mouse down?>
     <if><touching[ Enemy ]>
     <change{ score }by( 1 )
     <end>
   <end>
<end>
[/blocks]

as for the enemy, seans idea is quite nice in my opinion.

Sorry the cat and the bannana but i hardly ever use brodcasts and really isint needed

Last edited by yambanshee (2008-09-23 09:00:31)

Offline

 

Board footer