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

public class TestSection4 extends Applet implements ActionListener{
	int counter = 0;
	int[] asterX = {10, 40, 70, 100};
	int[] asterY = {150, 120, 90, 60};
	int[] asterSpeedX = {1, 2, 3, 4};
	int[] asterSpeedY = {5, 4, 3, 2};
	Timer timer;
	
	public void init(){
		timer = new Timer(50, this);
		timer.start();
	}
	
	public void paint(Graphics p){
		counter++;
		
		if(counter < 50){
			updateAsteroidCoordinates(asterX, asterY, asterSpeedX, asterSpeedY);
		}
		else{
			asterX[0]=10;
			asterX[1]=40;
			asterX[2]=70;
			asterX[3]=100;
			asterY[0]=150;
			asterY[1]=120;
			asterY[2]=90;
			asterY[3]=60;
			counter=0;
		}
		
		p.setColor(Color.BLACK);
		p.fillRect(0, 0, 400, 400);
		
		p.setColor(Color.GRAY);
		p.fillRect(asterX[0], asterY[0], 20, 20);
		p.drawString("x:"+asterX[0]+"  y:"+asterY[0], 20, 20);
		
		p.setColor(Color.RED);
		p.fillRect(asterX[1], asterY[1], 20, 20);
		p.drawString("x:"+asterX[1]+"  y:"+asterY[1], 20, 35);
		
		p.setColor(Color.GREEN);
		p.fillRect(asterX[2], asterY[2], 20, 20);
		p.drawString("x:"+asterX[2]+"  y:"+asterY[2], 20, 50);
		
		p.setColor(Color.BLUE);
		p.fillRect(asterX[3], asterY[3], 20, 20);
		p.drawString("x:"+asterX[3]+"  y:"+asterY[3], 20, 65);
	}
	
	
	// method that updates the locations of the asteroids and the ship
	public void updateAsteroidCoordinates(int[] asteroidX, int[] asteroidY, int[] asteroidSpeedX, int[] asteroidSpeedY){
		//####################################
		// FILL IN YOUR CODE HERE
		//####################################
	}
	
	
	//------------------------------------------------------------------
	// method that updates the x coordinate of a single asteroid
	public int updateXCoordinate(int x, int speed){
		return x+1;
	}
	
	
	//------------------------------------------------------------------
	// method that updates the y coordinate of a single asteroid
	public int updateYCoordinate(int y, int speed){
		return y+1;
	}
	
	
	//----------------------------------------------------------------------------------------------------
	// #####   RESPONSE TO USER INPUT METHODS   #######
	//----------------------------------------------------------------------------------------------------
	
	// timer went off, so repaint the window
	public void actionPerformed(ActionEvent event){
		repaint();
	}
}