New Snippet

Jump to navigation Jump to search

New Snippet

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);
Blubex21:22, 18 December 2011

You do not have permission to edit this page, for the following reasons:

  • The action you have requested is limited to users in the group: Users.
  • You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page.

Return to Thread:Category talk:Code Snippets/New Snippet/reply.

 

Thanks, making it now.

Blubex07:00, 19 December 2011