package Tools.Pixel2D;
import java.awt.*;
public class PixelObject{
public Color[][][] pixels;
private PixelObjectFunction[] functions;
public PixelScreen frame;
PixelLayer layer;
PixelGrid grid;
thread thread;
public int x;
public int y;
public int firstLayer;
private int pofs = 0;
public PixelObject(PixelScreen frame, PixelLayer layer) {
functions = new PixelObjectFunction[100];
this.frame = frame;
this.layer = layer;
thread = new thread();
thread.start();
}
public void setPosition(int x, int y, int firstLayer) {
this.x = x;
this.y = y;
this.firstLayer = firstLayer;
}
public void setGridPosition(int x, int y, int firstLayer) {
this.x = x*grid.getMultiple();
this.y = y*grid.getMultiple();
this.firstLayer = firstLayer;
}
public void setAllignedToGrid(PixelGrid g) {
grid = g;
}
public void setLayout(Color[][][] c) {
pixels = c;
}
public void setVisible(boolean vis) {
for(int i = 0; i < pixels.length; i++) {
for(int j = 0; j < pixels[i].length; j++) {
for(int k = 0; k < pixels[i][j].length; k++) {
if(vis) {
layer.setPixel(x+j, y+i, k+firstLayer, pixels[i][j][k]);
}
else {
layer.setPixel(x+j, y+i, k+firstLayer, null);
}
}
}
}
}
public void add(PixelObjectFunction f) {
functions[pofs] = f;
pofs++;
}
private void functionThread() {
System.out.println("b");
while(true) {
//System.out.println("c");
for(int i = 0; i < pofs; i++) {
System.out.println(i);
//if(functions[i].active) {
//functions[i].run();
//System.out.println(i);
//}
}
}
}
public class thread extends Thread {
public void run() {
System.out.println("a");
functionThread();
}
}
}