Direction of a movieclip using trig... plz help

I’m working on a game right now. It’s an asteroids type of game and I’ve just finnished programming the controls and making it shoot.

now for the questions:

  1. how do i make the bulltets shoot in the same direction that the ship was pointing at when the bullet was fired?

  2. how would i go about controlling the rate at which the bullets are fired?

  3. how would i get the bullets to be below the space ship when they are fired?

If anyone can answer any of these questions for me i would greatly appreciate it,

thanks.

-mike

p.s. if you need the file here it is…

Hey Mike,

  1. When the ship fires, set two variables for the bullet, one being the x movement and one being the y movement. these are set using

movement_x = Math.cos(ship._rotation*Math.PI/180)bullet_speed;
movement_y = Math.sin(ship._rotation
Math.PI/180)*bullet_speed;

  1. you can check for (I assume) a keydown using enterFrame. Then using mod an a frame count when that is detected you can control the interval at which the firing occurs

if(key.isDown(Key.SPACE)){
// fire key is pressed
if (firing++ % rate == 0){
// fire bullet - only every ‘rate’ frames
}else{
firing = 0; // reset counter when not firing
}
}

  1. attach (or duplicate) your bullets within a movieclip, not the same scope as the ship itself. Then just keep that moveiclip below the ship and every bullet will then be under the ship as well. Having this movieclip at 0,0 will mean clips (bullets) within that clip will have the same cooridinates within that movieclip as they would outside.

  2. Alos, if you could, please reduce the size of your footer to be at or below 15k (though you can get away with about 30 ;)). see http://www.kirupaforum.com/showthread.php?s=&threadid=12 for more information and footer guidelines.

thanks

uh… sorry about the footer size… exactly how large is it? I didnt think that the 5 jpegs would be that large…

also, i can’t seem to figure out how to get the bullet to fly at an angle… could you check the file out plz?

this is what i got…

movement_x = Math.cos(spcShp._rotation*Math.PI/180)*10;
movement_y = Math.sin(spcShp._rotation*Math.PI/180)*10;
this._x += movement_x;
this._y += movement_y;