game-of-prod/src/main/java/Block.java
2020-02-26 09:38:39 +02:00

33 lines
806 B
Java

import java.awt.*;
import java.util.Random;
public class Block extends Cell {
Random random;
public Block(){
super(-1, - 1, WindowOfFreeMove.CELL_SIZE, Color.BLUE);
this.random = new Random();
}
public Block(int x, int y){
super(x,y, WindowOfFreeMove.CELL_SIZE, Color.BLUE);
this.random = new Random();
}
public boolean isInBlock(int x, int y) {
if ((this.
getX() == x) && (this.getY() == y))
return true;
return false;
}
public void randomAppear() {
int x, y;
do {
x = random.nextInt(WindowOfFreeMove.CANVAS_HEIGHT);
y = random.nextInt(WindowOfFreeMove.CANVAS_WIDTH);
} while (WindowOfFreeMove.map.isBusyCell(x, y));
set(x, y);
}
}