# Angle shooting

**URL:** <https://forum.kirupa.com/t/angle-shooting/239897>\
**Category:** programming\
**Created:** [September 26, 2007, 11:28pm UTC](https://forum.kirupa.com/t/angle-shooting/239897 "2007-09-26T23:28:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cranky\_crank](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@cranky\_crank](https://forum.kirupa.com/u/cranky_crank)\
**Post date:** [September 26, 2007, 11:28pm UTC](https://forum.kirupa.com/t/angle-shooting/239897/1 "2007-09-26T23:28:20Z")

</div>

Hi, I am working on a tank game. Currently I have the movement down along with the barrel rotation. I have the bullets also working in the correct area (show up near the barrel). What I am having problems with is getting the bullets to shoot in the correct direction. Heres what I have for the first players movieclip.

```auto

onClipEvent(load){
 movespeed=5;
 barrelrotate=0;
}
onClipEvent(enterFrame){
 //left movement
 if(Key.isDown(65)){
  this._x-=movespeed;
 }
 //right movement
 if(Key.isDown(68)){
  this._x+=movespeed;
 }
 //scale tank
 if(Key.isDown(68)&&this._xscale==-100){
  this._xscale=100;
 }
 if(Key.isDown(65)&&this._xscale==100){
  this._xscale=-100;
 }
 //barrel movement
 if(Key.isDown(87)){
  if(barrelrotate!=50){
   this.barrel._rotation-=5;
   barrelrotate+=5;
  }
 }
 if(Key.isDown(83)){
  if(barrelrotate!=0){
   this.barrel._rotation+=5;
   barrelrotate-=5;
  }
 }
}
on(keyPress "g"){
 _root.p1ShootBullet();
}

```

and this I have on my maintimeline.

```auto

//p1 shooting
p1ShootBullet = function () {
 var Bullet = _root.attachMovie("Bullet", "Bullet"+Num, _root.getNextHighestDepth());
 var point = {x:this.p1.barrel.gunTip._x,y:this.p1.barrel.gunTip._y};
 this.p1.barrel.localToGlobal(point);
 Bullet._x = point.x;
 Bullet._y = point.y;
 Bullet.onEnterFrame = function() {
  //this is where the problem is
 }
 Num++;
}

```

Anyone have any ideas of a good way of making it go the correct direction?  
I uploaded a file to show it. (Its FLASH MX 2004 format)  
Oh, and heres a link to see the [swf](http://www.geocities.com/myhostedstuff/ShootingTest.swf).
