package game;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import piece.*;
import board.Board;
/**
*
* @author Paul J. Tanenbaum
*
*/
public class Game {
static Logger logger = Logger.getLogger(Game.class);
private static Board board;
private static final int NM_ROWS_DFLT = 20;
private static final int NM_COLS_DFLT = 10;
public static void main(String[] args) {
/*
* !!! Configure the logger BEFORE declaring variables !!!
*/
PropertyConfigurator.configure("log4j.properties");
/*
* Now, then, the variables...
*/
int dimensions[] = {NM_ROWS_DFLT, NM_COLS_DFLT};
Boolean syntaxError = false;
// Process any arguments
if (args.length == 2) {
for (int i = 0; i < 2; ++i) {
try {
dimensions[i] = Integer.parseInt(args[i]);
} catch (NumberFormatException e) {
System.err.println("Illegal argument: '" + args[i]
+ "' should be a positive integer");
syntaxError = true;
}
if (dimensions[i] <= 0) {
System.err.println("Illegal argument: '" + args[i]
+ "' should be a positive integer");
syntaxError = true;
}
}
} else if (args.length != 0) {
syntaxError = true;
}
if (syntaxError) {
System.err.println("Usage: tetanus [nmRows nmCols]");
System.exit(1);
}
// Create the board
board = new Board(dimensions[0], dimensions[1]);
// Start the game itself
play();
}
/**
* The overall logic of the game
*/
private static void play() {
Piece piece = new Eye();
piece.exploreShapeTypes();
piece.exploreStepSweep(piece, 1);
//while (true) {
for (int i = 0; i < 5; ++i) {
try {
piece = Piece.randomPiece(3, 7);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(1);
}
logger.info("The next piece is a " + piece.getClass());
piece.setRotation(1);
piece.prettyPrint();
piece.getFootprint();
piece.dissolve();
System.out.println();
}
}
}