105 lines
3.7 KiB
Java
105 lines
3.7 KiB
Java
package chess;
|
|
|
|
import chess.Util.Col;
|
|
import javalib.impworld.*;
|
|
|
|
class Game extends World {
|
|
Actor white;
|
|
Actor black;
|
|
Board board;
|
|
WorldScene scene;
|
|
|
|
Game(Actor white, Actor black, Board board) {
|
|
this.white = white;
|
|
this.black = black;
|
|
this.board = board;
|
|
}
|
|
|
|
Game() {
|
|
this(
|
|
new Player(Util.Col.WHITE), new Player(Util.Col.BLACK), new Board()
|
|
);
|
|
|
|
this.setup();
|
|
}
|
|
|
|
public WorldScene makeScene() {
|
|
this.scene = this.getEmptyScene();
|
|
this.draw();
|
|
return this.scene;
|
|
}
|
|
|
|
void run() {
|
|
this.bigBang(Util.boardW * Util.scale, Util.boardW * Util.scale, 0.01);
|
|
}
|
|
void draw() { this.scene = this.board.draw(); }
|
|
|
|
void setup() {
|
|
this.board.board.put(new Coord(0, 0), new Rook(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(1, 0), new Knight(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(2, 0), new Bishop(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(3, 0), new King(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(4, 0), new Queen(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(5, 0), new Bishop(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(6, 0), new Knight(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(7, 0), new Rook(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(0, 1), new Pawn(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(1, 1), new Pawn(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(2, 1), new Pawn(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(3, 1), new Pawn(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(4, 1), new Pawn(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(5, 1), new Pawn(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(6, 1), new Pawn(Util.Col.BLACK));
|
|
this.board.board.put(new Coord(7, 1), new Pawn(Util.Col.BLACK));
|
|
|
|
this.board.board.put(
|
|
new Coord(0, 0).rel(Util.Col.WHITE), new Rook(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(1, 0).rel(Util.Col.WHITE), new Knight(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(2, 0).rel(Util.Col.WHITE), new Bishop(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(3, 0).rel(Util.Col.WHITE), new King(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(4, 0).rel(Util.Col.WHITE), new Queen(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(5, 0).rel(Util.Col.WHITE), new Bishop(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(6, 0).rel(Util.Col.WHITE), new Knight(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(7, 0).rel(Util.Col.WHITE), new Rook(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(0, 1).rel(Util.Col.WHITE), new Pawn(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(1, 1).rel(Util.Col.WHITE), new Pawn(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(2, 1).rel(Util.Col.WHITE), new Pawn(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(3, 1).rel(Util.Col.WHITE), new Pawn(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(4, 1).rel(Util.Col.WHITE), new Pawn(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(5, 1).rel(Util.Col.WHITE), new Pawn(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(6, 1).rel(Util.Col.WHITE), new Pawn(Util.Col.WHITE)
|
|
);
|
|
this.board.board.put(
|
|
new Coord(7, 1).rel(Util.Col.WHITE), new Pawn(Util.Col.WHITE)
|
|
);
|
|
}
|
|
}
|