[COLOR=#000000][FONT=verdana]Ok i made a tank that can move and shoot but i want the bullet to bounce or “ricochet” off the walls so i gave it a shot but… the bullet bounces off the wall but after i shoot a couple they all suddenly are in sync [/FONT][/COLOR][COLOR=#000000][FONT=verdana] heres my code…
[/FONT][/COLOR][COLOR=#000000][FONT=verdana]
function mouseDown(pEvent){
if (amo >= 1) {
var b = new Bullet();
b.x = myTank.x;
b.y = myTank.y;
amo -= 1;
b.angleRadian = Math.atan2(mouseY - myTank.y,mouseX -myTank.x); b.addEventListener(Event.ENTER_FRAME, bulletEnterFrame);
addChild(b);
}}
function bulletEnterFrame(pEvent){
var b = pEvent.currentTarget;
b.x += Math.cos(b.angleRadian) * speed;
b.y += Math.sin(b.angleRadian) * speed;
b.rotation = b.angleRadian * 180 / Math.PI;
if (b.y < 0 || b.y > stage.stageHeight) {
speed = speed * -1;
b.x += Math.cos(b.angleRadian) * speed;
}
if(b.x < 0 || b.x > stage.stageWidth) {
speed = speed * -1;
b.rotation = b.rotation * -1;
}}
[/FONT][/COLOR][COLOR=#000000][FONT=verdana]any help would be appreciated…[/FONT][/COLOR]