import processing.core.PApplet;
import processing.core.PImage;

import java.util.LinkedList;
import java.util.Queue;

public class GraphicsProgram extends PApplet {

    private Queue<int[]> playerTrails = new LinkedList<>();

    PImage img1;
    PImage img2;
    PImage backgroundImage;

    public static void main(String[] args) {
        PApplet.main("GraphicsProgram");
    }

    public void settings() {
        fullScreen();
    }

    public void setup() {
        backgroundImage = loadImage("Background.png");
        backgroundImage.resize(1792, 1024);

        img1 = loadImage("TrailBlue.png");
        img2 = loadImage("TrailRed.png");
    }

    public void draw() {
        image(backgroundImage, 0, 0); // Hintergrund zeichnen


        int particleSizeP1 = 30;
        int particleSizeP2 = 30;



        // Kopie von trailPlayer1 erstellen und durch die Kopie iterieren
        for (int[] koordinates : new LinkedList<>(playerTrails)) {
            int x1 = koordinates[0];
            int y1 = koordinates[1];
            int x2 = koordinates[2];
            int y2 = koordinates[3];

            fill(0, 0, 255);
            rect(x1, y1, particleSizeP1, particleSizeP1);
            //image(img1, x1, y1, particleSizeP1, particleSizeP1);

            fill(255, 0, 0);
            rect(x2, y2, particleSizeP2, particleSizeP2);
            //image(img2, x2, y2, particleSizeP2, particleSizeP2);


        }

    }

    public void updateTrail(Queue<int[]> trails){
        this.playerTrails = trails;
    }
}
