game-of-prod/src/main/java/Block.java
2020-02-25 21:19:15 +02:00

30 lines
685 B
Java

import java.awt.*;
import java.util.Random;
public class Block extends Cell {
Random random;
Game game;
public Block(Game game){
super(-1, - 1, game.CELL_SIZE, Color.BLUE);
this.game = game;
this.random = new Random();
}
public boolean isInBlock(int x, int y) {
if ((this.
getX() == x) && (this.getY() == y))
return true;
return false;
}
public void appear() { // show food at new x,y coordinates
int x, y;
do {
x = random.nextInt(20);
y = random.nextInt(20);
} while (game.isBusyCell(x, y));
set(x, y);
}
}