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.
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.
//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.