Discussion:
DrawTarget not working
asherbaig
2008-12-17 17:06:02 UTC
Permalink
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);
}


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Robocode/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/Robocode/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:Robocode-***@yahoogroups.com
mailto:Robocode-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
Robocode-***@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
flemmingnlarsen
2008-12-17 22:45:06 UTC
Permalink
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
Post by asherbaig
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);
}
------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Robocode/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/Robocode/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:Robocode-***@yahoogroups.com
mailto:Robocode-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
Robocode-***@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

Loading...