import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class vcrJPanel1 extends JPanel 
{
	
	int step = 0;
	int trackPosY = -2000;
	int trackSpeed = 3;
	//int obsAPosX = 100;
	//int obsAPosY = 100;
	int carPosX = 275;
	int carPosY = 475;
	int carHealth = 100;
	
	obstacle myObstacle;
	track myTrack;
	car myCar;

	//Image[] obstacleImage = new Image[1000];
	//int[] obstaclePosX = new int[1000];
	//int[] obstaclePosY = new int[1000];
	//Image track = Toolkit.getDefaultToolkit().getImage("track_roaddry.jpg");
	//Image obstacleA = Toolkit.getDefaultToolkit().getImage("obj_pothole.gif");
	//Image car = Toolkit.getDefaultToolkit().getImage("car_buggy.gif");
	public vcrJPanel1(obstacle inputObstacle, track inputTrack, car inputCar)
	{
		myObstacle = inputObstacle;
		myTrack = inputTrack;
		myCar = inputCar;
		//Temp Loop to generate obstacles
		/*
		for (int a=0; a < 30; a++)
		{
			obstacleImage[a] = obstacleA;
			obstaclePosX[a] = 20+10*a;
			obstaclePosY[a] = 20+50*a;
			//System.out.println("X=" + obstaclePosX[a] + " Y=" + obstaclePosY[a]);
		}
		*/
		setBackground(Color.black);
	}
	
	public void paintComponent(Graphics g) 
	{		
		super.paintComponent(g);
		
		g.drawImage(myTrack.trackUsed, 0, 0+(step*trackSpeed), this);
		g.drawImage(myTrack.trackUsed, 0, -1000+(step*trackSpeed), this);
		g.drawImage(myTrack.trackUsed, 0, -2000+(step*trackSpeed), this);
		g.drawImage(myTrack.trackUsed, 0, -3000+(step*trackSpeed), this);
		g.drawImage(myTrack.trackUsed, 0, -4000+(step*trackSpeed), this);
		g.drawImage(myTrack.trackUsed, 0, -5000+(step*trackSpeed), this);
		g.drawImage(myTrack.trackUsed, 0, -6000+(step*trackSpeed), this);
		g.drawImage(myTrack.trackUsed, 0, -7000+(step*trackSpeed), this);
		g.drawImage(myTrack.trackUsed, 0, -8000+(step*trackSpeed), this);
		g.drawImage(myTrack.trackUsed, 0, -9000+(step*trackSpeed), this);
		g.drawImage(myTrack.trackUsed, 0, -10000+(step*trackSpeed), this);
		
		
		for (int a=0; a<myObstacle.arraySize; a++)
		{
			g.drawImage(myObstacle.objectsImage[a], myObstacle.objectsPosX[a], myObstacle.objectsPosY[a]+(step*trackSpeed), this);
		}
		
		/*
		g.drawImage(obstacleA, obsAPosX, obsAPosX+(step*trackSpeed), this);
		g.drawImage(obstacleA, obsAPosX+20, obsAPosX-100+(step*trackSpeed), this);
		g.drawImage(obstacleA, obsAPosX+40, obsAPosX-300+(step*trackSpeed), this);
		g.drawImage(obstacleA, obsAPosX+60, obsAPosX-500+(step*trackSpeed), this);
		g.drawImage(obstacleA, obsAPosX+80, obsAPosX-700+(step*trackSpeed), this);
		g.drawImage(obstacleA, obsAPosX+100, obsAPosX-900+(step*trackSpeed), this);
		*/
		g.drawImage(myCar.carUsed, carPosX, carPosY, this);
		g.setColor(Color.white);
		
	}

}