PDA

View Full Version : need help making enemy shoot



zevil
November 27th, 2006, 04:29 PM
i need help making an enemy shoot at my space ship.

bombsledder
November 27th, 2006, 04:59 PM
thats very descriptive sure i will help, let me just make a space ship, bullets an enemy and let me build it altogether and give you the code for free

zevil
November 27th, 2006, 05:06 PM
thanks
i've made all that stuff i just can't figure out the action script

mnkeymasta
November 27th, 2006, 05:09 PM
1. He's being sarcastic
2. Post the stuff
3. This has been posted before, check my sig
4. (-:

zevil
November 27th, 2006, 05:15 PM
o

zevil
November 27th, 2006, 05:20 PM
none of them answer my question when i searched them or at least not completely

zevil
November 27th, 2006, 05:22 PM
can't post it now i can't get to the files

zevil
November 27th, 2006, 05:24 PM
can't post it now i can't get to the files

bombsledder
November 27th, 2006, 09:49 PM
just post it when ever you get the chance and someone will gladly help you or point you in the right direction

shortwod
December 24th, 2006, 10:48 PM
I'm trying do the something and i would like know how to do this to for i can't find the info

Darth Arias
December 26th, 2006, 12:07 AM
try doing something first, then present your failed attempt...

Joppe
December 26th, 2006, 07:57 AM
^ That actually sounds evil. But its the way to go. =)

DangerousDan
December 26th, 2006, 12:56 PM
I'm assuming you want some AI here, check the X of the enemy and your ship, if they're close shoot otherwise keep moving or something...


if(this._X - ship.-X <= 20){ //if their Xs are within 20
shoot(); //do whatever you do to make the enemy fire.
}


If you're asking HOW to make the enemy shoot, then you have to attach a movie (the bullet) to the enemy and move it after wards, when it goes off the screen remove it.



bulletDepth = _root.getNextHighestDepth();
_root.attachMovie("bullet","bullet"+bulletDepth,bulletDepth);
this["bullet"+bulletDepth]._y = enemy._y;
this["bullet"+bulletDepth]._x = enemy._x;
this["bullet"+bulletDepth].onEnterFrame = function(){
this._y-= 5;
if(this._y < 0){
this.removeMovieClip();
}
//check for hit against ship too.
}


Something along those lines, I wrote this in the this little chatbox so the code may have some errors, as well as I'm writing the syntax off the top of my head so It may have some errors.

Look up: attachMovie() and removeMovieClip()

zevil
January 3rd, 2007, 07:09 PM
do i put this in a frame or into the enemy

bombsledder
January 3rd, 2007, 07:26 PM
you would put that on to a frame

zevil
January 3rd, 2007, 08:30 PM
should i create the bullet on the stage or export it for AS

DangerousDan
January 4th, 2007, 08:05 PM
You would export it.

zevil
January 12th, 2007, 01:14 PM
it would really help me if someone who knows how to do this would post an example FLA file because every time i try something NOTHING WORKS. would someone please post an example FLA

zevil
January 26th, 2007, 01:29 PM
Sum1 please post an example FLA!!! I can't do it!!! I've tried every way that I could think of and then sum!!! I've tried this way like 4 times!!!

SacrificialLamb
January 26th, 2007, 03:58 PM
Try this
http://www.kirupa.com/developer/actionscript/vertical_shooter.htm
work out how that works then start with something simpler, because if you can't get it to work from that code you should probably start with a simpler game. Then come back with a real attempt of your own

zevil
January 29th, 2007, 01:22 PM
no i want to make the enemys shoot not the main character

zevil
January 29th, 2007, 01:24 PM
how do you program the enemy 2 shoot when the enemy movieclip timeline reaches a specific frame?

SacrificialLamb
January 29th, 2007, 10:27 PM
why are you using a enemy timeline? For making a MC shoot every so often you would be better off using an interval or some other counting thing like this

onEnterFrame=function(){
i++
if(i>24){
i = 0
shoot()
}
}
Also I was not suggesting that that tutorial would show you just what you wanted but I thought by the sounds of things that you did not know enough to do this and could do with learning more then trying it your self

zevil
January 30th, 2007, 12:54 PM
What is "shoot()" supposed to be?

zevil
January 30th, 2007, 01:11 PM
i am also having trouble making the hit test work between the enemy's lazer and the space ship

this is what i have so far

zevil
February 20th, 2007, 12:53 PM
please help me

Lord Rahl
February 27th, 2007, 03:23 PM
Didn't check your file mainly because I have not been into flash for some time. But I noticed this post and figured you may want to take a peek at some of my old work. Its not the greatest and kinda sloppy in its AS, but it was back when I was still learning. :book:

It shows how to make enemies follow you, and the second enemy will rotate and continue to look at you. (I never got around to making them shoot, but you can probally figure it out on your own if you view the heros shooting code.)
Most of the code is on the main timeline, but the invisible barrier and crosshair have code within them.
Controls are as followed!
Arrow keys for movement or W,A,S,D
Click to shoot

FLA (http://www.geocities.com/myhostedstuff/ShootingGame.fla)
SWF (http://www.geocities.com/myhostedstuff/ShootingGame.swf)

zevil
March 6th, 2007, 12:59 PM
i have already tried modifying the the hero's script but failed.

pateucopt
March 6th, 2007, 01:18 PM
http://www.flashkit.com/tutorials/Games/Building-Flash_Ju-78/index.php

maybe this will help

zevil
April 16th, 2007, 01:30 PM
"What is "shoot()" supposed to be?"

SacrificialLamb
April 16th, 2007, 02:10 PM
a link to a function that as DangerousDan says "whatever you do to make the enemy fire.". so it's the proposed name of a function

LordArkain
April 16th, 2007, 09:40 PM
I modified Lord Rahls file so the turret would shoot. :look: Only I came across problems because im not used to his code. I couldn't get the intervals command to work with the turrets shotting function in it to shoot every 5 seconds. So far it just continously shoots. It's not perfect but it's something in the direction you wanted. I'm no master coder so maybe someone else can figure it out. :sigh: