import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;

import javax.swing.Timer;

public class TestSection12 extends Applet implements ActionListener{

	int counter = 0;
	int[] cargoX = {10, 30, 50, 70};
	int[] cargoY = {10, 10, 10, 10};
	int[] asteroidX = {10, 40, 70, 100};
	int[] asteroidY = {120, 90, 60, 30};
	
	boolean retry = false;
	Timer timer;
	Timer timer2;
	
	public void init(){
		setSize(400,400);
		timer = new Timer(50, this);
		timer.start();
		timer2 = new Timer(2000, this);
		timer2.start();
	}
	
	public void paint(Graphics p){
		
		p.setColor(Color.BLACK);
		p.fillRect(0, 0, 400, 400);
		
		
		p.setColor(Color.GRAY);
		for(int i=0; i<asteroidX.length; i++){
			p.fillRect(asteroidX[i], asteroidY[i], 20, 20);
		}
		
		p.setColor(Color.GREEN);
		for(int i=0; i<cargoX.length; i++){
			p.fillRect(cargoX[i], cargoY[i], 10, 10);
		}
	}
	
	
	//----------------------------------------------------------------------------------------------------
	// #####   INITIALIZATION STUFF   #######
	//----------------------------------------------------------------------------------------------------
	
	// method that randomly assigns locations to all cargo pieces and asteroids
	public void assignLocations(int[] cargoX, int[] cargoY, int[] asteroidX, int[] asteroidY){
		//####################################
		// FILL IN YOUR CODE HERE
		//####################################
	}
	
	
	
	
	// global variable used by all of the randomized methods
	Random gen = new Random();
	//------------------------------------------------------------------
	// method that returns a random number within the x bounds of the window
	public int randomX(){
		return gen.nextInt(212);
	}
	
	
	//------------------------------------------------------------------
	// method that returns a random number within the y bounds of the window
	public int randomY(){
		return gen.nextInt(339);
	}
	
	
	//----------------------------------------------------------------------------------------------------
	// #####   RESPONSE TO USER INPUT METHODS   #######
	//----------------------------------------------------------------------------------------------------
	
	// timer went off, so repaint the window
	public void actionPerformed(ActionEvent event){
		if(event.getSource().equals(timer2))
			this.assignLocations(cargoX, cargoY, asteroidX, asteroidY);
		
		repaint();
	}
}
