View source for Category talk:Code Snippets
Code Snippet "Rules"?
Just something I was thinking about when looking through some of the code snippets on the Radar page. Should there be some basic "guide lines" to follow when adding code snippets? One would think that as this is a great time to update a lot of the info on the pages being moved, it is also a great time to update all of the code snippets too. Just so you guys know what I'm talking about, I'll give you an example: always using radians. Now it's something that I don't do personally but in an effort but be consistent, maybe we should recode all of the snippets to use radians? Or maybe degrees, which ever. Also, proper commenting might be another good thing? The list really could go on... but I think you get what I'm saying...
Thoughts? --KID 01:57, 14 November 2007 (UTC)
- [View source↑]
- [History↑]
Contents
Thread title | Replies | Last modified |
---|---|---|
New Snippet | 2 | 06:00, 19 December 2011 |
I've got a bit of code for going straight to a corner. It needs to be optimized (choose best corner, etc.) but it's really useful for beginners. How do I create a new page in this category for it?
double x = getX() - getWidth() / 2;
double y = getY() - getWidth() / 2;
double a = Math.toDegrees(Math.atan(x / y));
double length = getBattleFieldWidth() - (getBattleFieldWidth() - getX());
double height = getBattleFieldHeight() - (getBattleFieldHeight() - getY());
double hypotenuse = Math.sqrt(length*length + height*height); //pythagorian theorum
turnRight(180 - getHeading() + a);
ahead(hypotenuse - 40);
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page.
Return to Thread:Category talk:Code Snippets/New Snippet/reply.