How to paint a laser that shows gun heading

[email protected] Sat, 28 Mar 2015 02:01:02 -0700 (PDT)
Newsgroups gmane.comp.java.robocode
Message-ID <[email protected]>
I want to see the robot's gun aiming trajectory. Basically a line that 
originates from the robot and ends at the at a point where the robot is 
currently aiming at.

public void onPaint(Graphics2D g){
  
                       int laserLength = 200;
                       double  heading =getGunHeading();
                       g.setColor(Color.RED);

double x = Math.sin(Math.toRadians(heading)) * laserLength;
        double y = Math.cos(Math.toRadians(heading)) * laserLength;
g.drawLine((int)getX(),(int) getY(), (int)x,(int) y);

}

Laser points at an irrelevant direction. How can I fix it?

-- 
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.