Place several large dots on the screen. Record the size and position of these large dots in arrays. Use the snippet below to get the Turtle moving. Modify the while loop in such a way that when your distance from the center of any dot is less than the radius you will print a message that says "Your turtle has exploded" and stops the program. (Essentially, if you run over any of the dots you placed in the arrays you will die.) Also stop the game if the turtle runs off the side of the screen.
I would suggest making 3 one dimensional arrays of all the same length.
int[] x = new int[]{...};
int[] y = new int[]{...};
int[] r = new int[]{...}; //This is the radius of the dot
Here is a quick way to loop through the arrays.
for(int i=0; i<x.length; i++) System.out.println("There is a dot at ("+x+","+y+") with a radius of "+r);
Movement Snippet
boolean pressed=false;
Turtle bob = new Turtle();
bob.speed(100);
bob.delay(0); //Shows the screen.
while(true)
{
//These if statements are to make you turn only once per key press.
if(StdDraw.isKeyPressed('a')&&!pressed)
{
pressed=true;
bob.left(30);
}
else if(StdDraw.isKeyPressed('d')&&!pressed)
{
pressed=true;
bob.right(30);
}
else if(!StdDraw.isKeyPressed('d')&&!StdDraw.isKeyPressed('a'))
{
pressed=false;
}
bob.forward(5);
//At this point I would loop through all the dots and see if you are too close.
}
There are great opportunities to extend this assignment. You could add a loop counter and print out the final value at the end to give the user an idea of how good they did. You could also add additional bombs as time goes on to ensure that the user will be challenged.
Alternative Game: You could make the player have to hit all the dots, similar to snake. As the turtle hits each dot, you could temporarily move to the center of the dot and repaint it another color and remove it from the array so that the user knows that it is no longer active.