Hi, Kirupians!
I’m working on a top-view game in which you control a tank that fires from a rotating turret (similar to the Wii Play game Tanks). I’ve got the movement and rotation of the turret down, and I’m using this code for the turret rotation:
_root.onEnterFrame = function(){
turretRadians = Math.atan2(_ymouse - player._y, _xmouse - player._x);
turretDegrees = Math.round((turretRadians*180/Math.PI));
player.player_turret._rotation = turretDegrees;
}
That part works just fine, but I’m still having trouble with getting the bullets to fire in the direction I want where I click. I’ve seen this tutorial, but I’d prefer to not just rotate a movie clip, as I may program in ricocheting bullets.
Should I be using trigonometry, algebra, or what? Any help would be very appreciated!
[EDIT] By the way, I’m using Flash 8.