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

#1 2009-04-05 12:27:53

Stickman704
Scratcher
Registered: 2009-01-31
Posts: 1000+

Doing computer players

Hello scratch!

I might be doing this kind of space invaders/star fox kind of game.
I'll try to explain in more detail.
You are in a ship and go through scroll y blasting 100s of little ships to get to your destination. The little ships will try to stop you and fire at you. How do i make them fire at me? I'll try it later and i'll come up with the results.

http://scratch.mit.edu/projects/Stickman704/478438

i've done it fine. So...

<{ X of you }>
<{ Y of you }>

You:
<when green flag clicked>
<forever>
<set{ X of you }to( <x position>
<set{ Y of you }to( <y position>
<end>

Enemy:
<when green flag clicked>
<forever>
<wait( 3 )secsc>
<broadcast[ Fire
<wait( 3 )secsc>
<end>

Blast:
<when green flag clicked>
<go to[ Enemy
<forever if><touching[ Death box for blast
<go to[ enemy
<end> 


<when I receive[ Fire
<glide( 3 )secs to x sad  <{ X of you }> )y sad  <{ Y of you }>
<go to[ enemy



Death box for blast:
<when green flag clicked>
<forever>
<set[ Ghost ]effect to(100
<end>

is there a quicker way?

Last edited by Stickman704 (2009-04-05 13:05:43)


Dun dun dun dun dun dun.... dun dun dun dun dun dun...  tongue

Offline

 

#2 2009-05-19 20:42:07

iab97
Scratcher
Registered: 2009-04-04
Posts: 100+

Re: Doing computer players

Sorry, I currently don't know a faster way—but good-job on your program!


-iab97 One of my favorite quotes: "You can't direct the wind, but can adjust your sails." -Unknown

Offline

 

#3 2009-05-21 07:53:40

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

Re: Doing computer players

try use as many local variables as possible when making AI

Offline

 

#4 2009-05-21 11:45:18

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: Doing computer players

Don't use the glide block. That'll make the AI dumb as heck >_>

First, click the [<-->] icon at the left of the sprite thumbnail, above the "Scripts" tab. That'll make it aim to only 2 directions, no matter if the direction isn't 90 or -90.

Then, use this:

[blocks]
<when green flag clicked>
<forever>
<point towards( player
<move( 5 )steps> --Change this to what you'd like. You can also use a "Pick Random" block.
<end>[/blocks]

Last edited by technoguyx (2009-05-21 11:45:44)


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#5 2009-05-21 12:18:00

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Doing computer players

Space shooters don't have enemy AIs. They have pre programed routines for the enemies.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

Board footer