Skip to content

Instantly share code, notes, and snippets.

@ckwang8128
Forked from bh3/BBall.java
Created August 8, 2012 20:40
Show Gist options
  • Select an option

  • Save ckwang8128/3298514 to your computer and use it in GitHub Desktop.

Select an option

Save ckwang8128/3298514 to your computer and use it in GitHub Desktop.
Google Basketball Doodle Solution (Java)
import java.awt.Robot;
import java.awt.AWTException;
import java.awt.event.KeyEvent;
public class BBall {
public static void main(String[] args) throws AWTException {
Robot rob = new Robot();
int delay[] = { 300, 220, 840, 1000, 1150, 1500};
int repeat[]= { 3, 2, 5, 5, 4, 2};
rob.delay(2000);
rob.mousePress(KeyEvent.BUTTON1_MASK);
rob.delay(100);
rob.mouseRelease(KeyEvent.BUTTON1_MASK);
rob.delay(500);
for(int i=0; i<delay.length; i++) {
for(int j=0; j<repeat[i]; j++) {
rob.keyPress(KeyEvent.VK_SPACE);
rob.delay(delay[i]);
rob.keyRelease(KeyEvent.VK_SPACE);
rob.delay(440); //450
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment