package agaroyun.view;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;

import javax.swing.JPanel;

import agaroyun.Model.GameObject;
import agaroyun.Model.Player;
	/**
	 * draws GameObjects to panel
	 * @author varyok
	 * @version 1.0
	 */
public class GamePanel extends JPanel {
	
	private ArrayList<GameObject> gameObjects;
	/**
	 * Keeps gameObjects ArrayList
	 * @param gameObjects
	 */
	public GamePanel(ArrayList<GameObject> gameObjects) {
	
			this.gameObjects=gameObjects;
			
	}
	/**
	 * draws GameObjects to panel
	 */
	@Override
	protected synchronized void paintComponent(Graphics g) {
		super.paintComponent(g);
		Graphics2D g2d=(Graphics2D)g; //Graphics 2d daha fazla özellik sağlayabilir. daha kolaydır
		
		for (GameObject gameObject : gameObjects) {
			gameObject.draw(g2d);
			
		}
		
	}
	
}
