Beispiel #1
0
  public MITrisPlugin(Display2D display, double framerate) throws IOException {
    super(display, framerate);
    timestep = 1 / framerate;
    width = display.getWidth();
    height = display.getHeight();
    servSock = new ServerSocket(12345);
    servSock.setSoTimeout(20);

    System.out.println("Game paused until client connect");

    gameState = State.IDLE;
  }
Beispiel #2
0
 private void sendBoardToDisplay(MITrisBoard board, Display2D display, double brightness) {
   int width = display.getWidth();
   int height = display.getHeight();
   for (int x = 0; x < width; x++) {
     for (int y = 0; y < height; y++) {
       Piece p = board.getPosition(x, y);
       Color c = p == null ? Color.BLACK : p.getColor(board.getLevel(), gameDisplayTime);
       float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), new float[3]);
       hsb[2] *= brightness;
       display.setPixelHSB(x, height - 1 - y, hsb[0], hsb[1], hsb[2]);
     }
   }
 }