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

public class TestSection8 extends Applet implements ActionListener{
	int counter = 0;
	int counter2 = 0;
	int[] x = {1, 1, 1, 1};
	int[] y = {1, 1, 1, 1};
	int shipX=0;
	int shipY=0;
	boolean[] cargoDrawn = {true, true, true, true};
	Timer timer;
	
	public void init(){
		timer = new Timer(50, this);
		timer.start();
	}
	
	public void paint(Graphics p){
		counter++;
		
		if(counter < 20){
		}
		else{
			x[counter2] = (x[counter2]+1)%2;
			y[counter2] = (y[counter2]+1)%2;
			counter2 = (counter2+1)%cargoDrawn.length;
			counter=0;
			if(x[0] != 0){
				cargoDrawn[0] = true;
				cargoDrawn[1] = true;
				cargoDrawn[2] = true;
				cargoDrawn[3] = true;
			}
		}
		
		p.setColor(Color.BLACK);
		p.fillRect(0, 0, 400, 400);
		
		//####################################
		// CALLING AND TESTING YOUR CODE
		if(gameLost(x, y, shipX, shipY))
			p.setColor(Color.RED);
		else
			p.setColor(Color.GREEN);
		
		//####################################
		// CALLING AND TESTING YOUR CODE
		p.drawString("Game Lost?: "+gameLost(x, y, shipX, shipY), 2, 12);
		
		if(0 == x[0])
			p.setColor(Color.RED);
		else
			p.setColor(Color.GREEN);
		p.drawString("collision with object 0? : "+(0 == x[0]), 2, 25);
		
		if(0 == x[1])
			p.setColor(Color.RED);
		else
			p.setColor(Color.GREEN);
		p.drawString("collision with object 1? : "+(0 == x[1]), 2, 40);
		
		if(0 == x[2])
			p.setColor(Color.RED);
		else
			p.setColor(Color.GREEN);
		p.drawString("collision with object 2? : "+(0 == x[2]), 2, 55);
		
		if(0 == x[3])
			p.setColor(Color.RED);
		else
			p.setColor(Color.GREEN);
		p.drawString("collision with object 3? : "+(0 == x[3]), 2, 70);
	}
	
	
	//------------------------------------------------------------------
	// method that checks for asteroid collisions with the ship and returns true/false if the game has been lost
	public boolean gameLost(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 asteroidCollision(int x, int y, int shipX, int shipY){
		if(x == shipX && y == shipY)
			return true;
		else
			return false;
	}
	
	
	//----------------------------------------------------------------------------------------------------
	// #####   RESPONSE TO USER INPUT METHODS   #######
	//----------------------------------------------------------------------------------------------------
	
	// timer went off, so repaint the window
	public void actionPerformed(ActionEvent event){
		repaint();
	}
}