DrawTarget not working

View: New views
2 Messages — Rating Filter:   Alert me  

DrawTarget not working

by asherbaig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,Thanks for your help.

In my robot i have added the given below features in order to drawOval
around my target but it is not working.Please help me solving this issue.

Thanks,
Asher


public void drawTarget
        (Graphics2D g, Color color,
        String name,Point2D point)  {

        g.setColor(color);

        double x = point.getX();
        double y = point.getY();

        g.drawString(name,(float)x+10,(float)y+10);
        g.drawLine((int)x, (int) y+5, (int) y+15, aimX);
        g.drawLine((int)x, (int) y+5, (int) y-15,aimY);
        g.drawLine((int)x+5, (int) y, (int) y,aimX);
        g.drawLine((int)x-5, (int) 5, (int) y,aimY);

        g.drawOval(
        (int) x-10,
        (int)y-10,
        (int)20,
        (int)20);
}


Re: DrawTarget not working

by flemmingnlarsen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It's hard to tell exactly what could be your problem. But first of
all, your drawTarget() methods should be called from your
onPaint(Graphics2D) method
(http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html#onPaint(java.awt.Graphics2D))
or you should use the new getGraphics() method instead.

Also make sure to enable the Paint button on your robot console in
order to see the paintings for your robot.

Read my tutorial here, to learn more about this topic:

http://testwiki.roborumble.org/w/index.php?title=Robocode/Graphical_Debugging

Best regards,
- Flemming


--- In Robocode@..., "asherbaig" <devilvsevil@...> wrote:
>
> Hi,Thanks for your help.
>
> In my robot i have added the given below features in order to drawOval
> around my target but it is not working.Please help me solving this
issue.

>
> Thanks,
> Asher
>
>
> public void drawTarget
> (Graphics2D g, Color color,
> String name,Point2D point)  {
>
> g.setColor(color);
>
> double x = point.getX();
> double y = point.getY();
>
> g.drawString(name,(float)x+10,(float)y+10);
> g.drawLine((int)x, (int) y+5, (int) y+15, aimX);
> g.drawLine((int)x, (int) y+5, (int) y-15,aimY);
> g.drawLine((int)x+5, (int) y, (int) y,aimX);
> g.drawLine((int)x-5, (int) 5, (int) y,aimY);
>
> g.drawOval(
> (int) x-10,
> (int)y-10,
> (int)20,
> (int)20);
> }
>