little help
Hi mate. You can change the color with:
public void run() {
// all the same color
setAllColors(Color.RED);
// or different for body , gun , radar
setRadarColor(Color.GREEN);
setGunColor(Color.BLUE);
setBodyColor(Color.BLACK);
...
}
You can make a bookmark to the robocode api Robocode API and there you find all the functions you can use. It looks a bit complicated if you are not familiar whit this kind of documentation but with a little help you get used to it very quickly.
For example if you look for the color. Hit the "AdvancedRobot" in the left frame "All Classes" and search just for "Color" in the right frame. Every function has a short description so just poke around a little.
And don't be shy just ask whatever you wan't to know.
take care
The API is your best friend. I also suggest you bookmark the Java API. The API documentation is a very useful set of documents.
For your purposes, java.lang.Math which has math methods, java.awt.geom which has geometry, and java.util which holds most generic data structures (maps, lists, sets, etc) are the packages you will likely use the most.
Within the robocode API, AdvancedRobot is a big bit of useful reference.
Whenever I try to change the colour it comes up with this error message
Compiling... BOSSSSS.java:15: cannot find symbol symbol : variable Colour location: class b.BOSSSSS
setallcolours(Colour.RED); ^
1 error Compile Failed (1)
Im a complete newby so I don't know what to do. Anyone Help?
Two things:
- The caps and (non-British) spelling matter:
setAllColors(Color.RED);
- You might need to import the Color class at the top of your file:
import java.awt.Color;
Nope, you can only fire one bullet at a time, and you have to wait 11-16 ticks before firing another one, depending on the bullet power you use. A lot information about the basic rules / physics of Robocode can be found at Robocode/FAQ.
You can adjust the gun cooling rate if you want to do it just for fun, but under the normal rules everyone else (and the RoboRumble) uses, no you can't. I think the gun cooling rate can be adjusted in settings, but it might be something directly in robocode.properties, I'm not sure...
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page.
Please, format yours code and in future use tag <syntaxhighlight>. What kind of error message you get?
Can you post the error message? Looks like you missed the onScannedRobot(ScannedRobotEvent e) Method.
<syntaxhighlight>Compiling... Arg.java:32: package Point2D does not exist public Point2D.Double guessPosition(long when) {
^
Arg.java:36: cannot find symbol symbol : variable time location: class argeaer.Arg
double diff = when - time; ^
Arg.java:40: cannot find symbol symbol : variable changehead location: class argeaer.Arg
if (Math.abs(changehead) > 0.00001) { ^
Arg.java:41: cannot find symbol symbol : variable speed location: class argeaer.Arg
double radius = speed/changehead; ^
Arg.java:41: cannot find symbol symbol : variable changehead location: class argeaer.Arg
double radius = speed/changehead; ^
Arg.java:42: cannot find symbol symbol : variable changehead location: class argeaer.Arg
double tothead = diff * changehead; ^
Arg.java:43: cannot find symbol symbol : variable y location: class argeaer.Arg
newY = y + (Math.sin(heading + tothead) * radius) - ^
Arg.java:43: cannot find symbol symbol : variable heading location: class argeaer.Arg
newY = y + (Math.sin(heading + tothead) * radius) - ^
Arg.java:43: sin(double) in java.lang.Math cannot be applied to (<nulltype>)
newY = y + (Math.sin(heading + tothead) * radius) - ^
Arg.java:44: cannot find symbol symbol : variable heading location: class argeaer.Arg
(Math.sin(heading) * radius); ^
Arg.java:43: operator - cannot be applied to <nulltype>,double
newY = y + (Math.sin(heading + tothead) * radius) - ^
Arg.java:45: cannot find symbol symbol : variable x location: class argeaer.Arg
newX = x + (Math.cos(heading) * radius) - ^
Arg.java:45: cannot find symbol symbol : variable heading location: class argeaer.Arg
newX = x + (Math.cos(heading) * radius) - ^
Arg.java:46: cannot find symbol symbol : variable heading location: class argeaer.Arg
(Math.cos(heading + tothead) * radius); ^
Arg.java:46: cos(double) in java.lang.Math cannot be applied to (<nulltype>)
(Math.cos(heading + tothead) * radius); ^
Arg.java:45: operator - cannot be applied to <nulltype>,double
newX = x + (Math.cos(heading) * radius) - ^
Arg.java:51: cannot find symbol symbol : variable y location: class argeaer.Arg
newY = y + Math.cos(heading) * speed * diff; ^
Arg.java:51: cannot find symbol symbol : variable heading location: class argeaer.Arg
newY = y + Math.cos(heading) * speed * diff; ^
Arg.java:51: cannot find symbol symbol : variable speed location: class argeaer.Arg
newY = y + Math.cos(heading) * speed * diff; ^
Arg.java:51: incompatible types found : <nulltype> required: double
newY = y + Math.cos(heading) * speed * diff; ^
Arg.java:52: cannot find symbol symbol : variable x location: class argeaer.Arg
newX = x + Math.sin(heading) * speed * diff; ^
Arg.java:52: cannot find symbol symbol : variable heading location: class argeaer.Arg
newX = x + Math.sin(heading) * speed * diff; ^
Arg.java:52: cannot find symbol symbol : variable speed location: class argeaer.Arg
newX = x + Math.sin(heading) * speed * diff; ^
Arg.java:52: incompatible types found : <nulltype> required: double
newX = x + Math.sin(heading) * speed * diff; ^
Arg.java:54: package Point2D does not exist
return new Point2D.Double(newX, newY); ^
25 errors Compile Failed (1)
This errors does not match to code. But i may guess, that you need to read about java "package" and "import" keywords and in common some basic book about java
Java Tutorial is a good place to learn Java.
And after getting used to the language, I recommend using some advanced IDE like Eclipse. All the errors above would be automatically corrected by pressing Ctrl-Shift-O.