import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import javax.swing.Timer;

public class TestSection6 extends Applet implements ActionListener{
	int counter = 0;
	int counter2 = 0;
	int x1=0; 
	int y1=20; 
	int x2=100; 
	int y2=30;
	
	int x3=20; 
	int y3=70; 
	int x4=60; 
	int y4=95;
	int x5=100; 
	int y5=80;
	Timer timer;
	
	public void init(){
		timer = new Timer(50, this);
		timer.start();
	}
	
	public void paint(Graphics p){
		counter++;
		
		if(counter < 75){
			x1++;
			x2--;
			x3++;
			x4++;
			x5--;
		}
		else{
			x1 = 0;
			x2 = 100;
			x3 = 20;
			x4 = 60;
			x5 = 100;
			counter=0;
		}
		
		p.setColor(Color.BLACK);
		p.fillRect(0, 0, 400, 400);
		
		//####################################
		// CALLING AND TESTING YOUR CODE
		if(asteroidCollision(x1, y1, x2, y2))
			p.setColor(Color.RED);
		else
			p.setColor(Color.BLUE);
		
		p.fillRect(x1, y1, 20, 20);
		p.fillRect(x2, y2, 20, 20);
		
		//####################################
		// CALLING AND TESTING YOUR CODE
		if(cargoCollision(x3, y3, x5, y5))
			p.setColor(Color.RED);
		else
			p.setColor(Color.BLUE);
		
		p.fillRect(x3, y3, 10, 10);
		
		//####################################
		// CALLING AND TESTING YOUR CODE
		if(cargoCollision(x4, y4, x5, y5))
			p.setColor(Color.RED);
		else
			p.setColor(Color.BLUE);
		
		p.fillRect(x4, y4, 10, 10);
		
		//####################################
		// CALLING AND TESTING YOUR CODE
		if(cargoCollision(x3, y3, x5, y5) || cargoCollision(x4, y4, x5, y5))
			p.setColor(Color.RED);
		else
			p.setColor(Color.BLUE);
		
		p.fillRect(x5, y5, 20, 20);
	}
	
	

	//------------------------------------------------------------------
	// method that checks for a collision between the given asteroid and the ship
	public boolean asteroidCollision(int x, int y, int shipX, int shipY){
		//####################################
		// FILL IN YOUR CODE HERE
		//####################################
	}
	
	
	//------------------------------------------------------------------
	// method that checks for a collision between the given cargo piece and the ship
	public boolean cargoCollision(int x, int y, int shipX, int shipY){
		//####################################
		// FILL IN YOUR CODE HERE
		//####################################
	}
	

	
	
	//----------------------------------------------------------------------------------------------------
	// #####   RESPONSE TO USER INPUT METHODS   #######
	//----------------------------------------------------------------------------------------------------
	
	// timer went off, so repaint the window
	public void actionPerformed(ActionEvent event){
		repaint();
	}
}