Discussion:
Targeting & Moving gun
n***@rocketmail.com
2009-12-01 21:32:32 UTC
Permalink
hello!

im quite new in robocode. I was checking around the tutorials on the wiki about targeting, and i found something that sounds strange to me.

In every kind of gun there is always some kind of calculation of the angle the gun has to be turned by. Then in the method onScannedRobot they do like this

public void ScannedRobot(ScannedRobotEvent e) {

...

setTurnGurRightRadians(someAngle);
setFire(somePower);
execute();
}

BUT in this way they are not really firing in the direction planned, because the two actions starts together.

Why they do like this? I would rather do something like this.

public void ScannedRobot(ScannedRobotEvent e) {

...

setTurnGurRightRadians(someAngle);
addCustomEvent( new GunTurnCompleteCondition());

}

public void onCustomEvent(CustomEvent e) {
fire(somePower);
}

I tried it and it works but it loses ticks around and don't fires at the same speed.. Can someone explain me this stuff?

Thank you





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

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:
Robocode-***@yahoogroups.com
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...