PDA

View Full Version : [AS2] Reflection the direction of a bullet


PhatKitty
04-23-2009, 08:50 PM
I'm making a game which is based on tanktrouble, I have a rotation tank and bullets but I have a problem with the boundary's. I want the bullets to behave in the same manner as they do in tanktrouble, so I made 2 separate boundary's horizontal and vertical ones, for the vertical I did bullet's xspeed *= -1, this reflects the bullet, and I did the same thing for the horizontal but did the yspeed.

This works just fine except when I get to the end of a wall, then the ball will go through the wall and shake lots. And it doesn't reflect accurately from a rounded surface, like my corners.

Sorry if that's confusing it's kind of hard to write my problem. What I need is script for 1 mc which will be the entire boundary's that will make a accurate reflection when hit by my bullets.

I have to go now so I won't reply =/ please leave some suggestions for when I get back in a few hours or tomorrow thanks :D.

pradvan
04-28-2009, 02:56 PM
Maybe if you post some code (in code tags) someone will take a look.

cjx3711
04-28-2009, 04:24 PM
Well, I had a problem like yours but I don't know if this helps. Instead of just changing the direction of the bullet, you should set the coordinates. For example.

if (bullet._x > 500) {
bullet._x = 500;
bulletSpeed *= -1;
}

I hope this helps.