# Talk:Linear Targeting/Buggy Implementations

< Talk:Linear Targeting

Jump to navigation
Jump to search
Revision as of 00:43, 10 April 2009 by CrazyBassoonist (talk | contribs)

These code snippets should be modified to not have super long lines. Also, there's no reason for the last one to be indented across the whole snippet. --Voidious 19:43, 14 November 2007 (UTC)

double absBearing=e.getBearingRadians()+getHeadingRadians(); double eX=getX() + e.getDistance() * Math.sin(absBearing); double eY=getY() + e.getDistance() * Math.cos(absBearing); eXChange=(eX-oldX)*(e.getDistance()/11); eYChange=(eY-oldY)*(e.getDistance()/11); oldX=getX() + e.getDistance() * Math.sin(absBearing); oldY=getY() + e.getDistance() * Math.cos(absBearing); double enemyLocation=robocode.util.Utils.normalAbsoluteAngle(Math.atan2((eX-getX())+eXChange,(eY-getY())+eYChange)); setTurnGunRightRadians(robocode.util.Utils.normalRelativeAngle(enemyLocation-getGunHeadingRadians())); setFire(3);

I'm trying to make a gun that makes use of code similar to this, but for some reason this doesn't work exactly right... Does anyone know if this is a math problem or a programming problem?--CrazyBassoonist 22:43, 9 April 2009 (UTC)