So ok. Im using CDK for my collision detection. So far, its been really helpfull.
But the function i wrote(with the help of cdk examples) just makes the players object(the tank) stop instead of continuing along the border of the object.
this is the game so far:
http://www.swfcabin.com/open/1257644383
the code:
function checkCollisions(){
colResultArray=colList.checkCollisions();
if(colResultArray.length)
{
var collision:Object = colResultArray0;
var angle:Number = collision.angle;
var overlap:int = collision.overlapping.length;
var sin:Number = Math.sin(angle);
var cos:Number = Math.cos(angle);
var vx0:Number = Chasis.vx * cos + Chasis.vy * sin;
var vy0:Number = Chasis.vy * cos – Chasis.vx * sin;vx = vx0 * cos – vy0 * sin;
vy = vy0 * cos + vx0 * sin;
}
}
arrow rotates in the direction of vx and vy.
Chasis.vx and Chasis.vy is the current x and y speed of the tank.
after vx and vy are calculated, the same movement algorythm used to mave the object normally is used, but the vx and vy are reversed(-= instead of +=)
How do i make it continue moving along the border? Making it less bumpy would also help.
Loading