Java
UNIT CHALLENGES

separator-blank.png

CHALLENGE


separator-blank.png

CHALLENGE 2 – ANIMATED GRAPHICS

SETUP

You will start by running this program. It is important that you understand how it works.

public class AnimGFX

{

    public static void main(String[] args)

    {

         NOOPDraw.createWindow(495,500,"Vertical Lines");

        

         for(int x=20; x<=460; x=x+10)

         {

             NOOPDraw.drawLine(x, 0, x, 460);

         }

    }
}


The program above creates the following line pattern:

 

 

 

WORK

You must alter the above program to make one of the lines be red.  Every frame, the red line is moved over to the next line.  And once that last line is red, then the red line returns to the first line.

The delay between frames is 100 milliseconds.

Click on the image to see a Flash video.

 

 

HINT: The FOR loop from the program above needs to be placed inside of a while loop.  Each pass in the while loop will represent a single frame.

separator-campeau.png