Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //That's on update
- moveBy(Math.sin(angle * DEGTORAD) * speed, Math.cos(angle * DEGTORAD) * -speed, "track", false);
- //That's on the class
- public function determineCollision():void
- {
- var sumAngle:Number = 360 / POINTS;
- var currentAngle:Number = 0;
- var totalX:Number = 0;
- var totalY:Number = 0;
- var n:int = 0;
- testingMC.graphics.clear();
- for(var i:int = 0; i < POINTS; ++i)
- {
- FP.angleXY(p, currentAngle, RADIUS, x, y);
- if(gameWorld.track.collidePoint(0, 0, p.x, p.y))
- {
- totalX += p.x;
- totalY += p.y;
- ++n;
- testingMC.graphics.beginFill(0x0000FF);
- }
- else
- {
- testingMC.graphics.beginFill(0xFF0000);
- }
- testingMC.graphics.drawRect(p.x, p.y, 1, 1);
- currentAngle += sumAngle;
- }
- p.x = totalX / n;
- p.y = totalY / n;
- angle = (angle + FP.angle(x, y, p.x, p.y)) * 0.5;
- var p2:Point = new Point;
- FP.angleXY(p2, angle, 30, x, y);
- testingMC.graphics.lineStyle(1, 0x00FF00);
- testingMC.graphics.moveTo(x, y);
- testingMC.graphics.lineTo(p2.x, p2.y);
- testingMC.graphics.beginFill(0xFFFF00);
- testingMC.graphics.drawCircle(p2.x, p2.y, 2);
- }
- override public function moveCollideX(e:Entity):Boolean
- {
- determineCollision();
- return false;
- }
- override public function moveCollideY(e:Entity):Boolean
- {
- determineCollision();
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement