Hi Experts,
I found this tutorial in the net:
Code:
http://www.foundation-flash.com/tutorials/turretpart1/
But hes not explaining the parts of the code.I Want to make a game that fires a ball which can bounce at opposite angles to inclined walls.I want to know how to get the ball bounce in opp direction to the angle it hits the walls.I found this,but not getting the logic please help.
Actionscript Code:
mousex = _xmouse-this._x;
mousey = (_ymouse-this._y)*-1;
angle = Math.atan(mousey/mousex)/(Math.PI/180);
mousex is the X distance and mousey is the Y distance.Math.atan for finding the angle.But
Y did he multiplied mousey with -1 ?
Actionscript Code:
if (mousex<0) {
angle += 180;
}
if (mousex>=0 && mousey<0) {
angle += 360;
}
this.cannon._rotation = (angle*-1)+90;
Whats this for?180 is a straight line isnt it?if he adds 180 when mousex is behind negative x axis,the angle will go down rite?And y dud he multiplied angle*-1 and added 90?What is the angle distribution in flash?
Actionscript Code:
start_ball_x = turret._x+30*Math.cos(angle*Math.PI/180);
y +30?
Actionscript Code:
cannonball_fired.dirx = Math.cos(angle*Math.PI/180)*15;
*15 must be its speed?
How can i detect the angle of collision with the wall?and will the abv (dirx) code with angle=180-angle will move it the opposite direction after collision?
I knw its kind of noobish...but please help
...


