Advertisement
dawdadwg

Untitled

Oct 15th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. import java.awt.Color;
  2. import processing.core.PApplet;
  3.  
  4. public class Board {
  5.  
  6.     private Tile[][] board = new Tile[8][8];
  7.     private int mouseX, mouseY;
  8.    
  9.     public Board()
  10.     {
  11.         int y = 0;
  12.         for(int i = 0; i < 8; i++)
  13.         {
  14.             int x = 0;
  15.             for (int j = 0; j < 8; j++)
  16.             {
  17.                
  18.                 board[i][j] = new Tile(x, y, null);
  19.                 x += 50;
  20.             }
  21.             y += 50;
  22.         }
  23.        
  24.         for(int i = 0; i < 8; i++)
  25.         {
  26.             for (int j = 0; j < 8; j++)
  27.             {
  28.                 if (i%2 == 0)
  29.                 {
  30.                     if (j%2 == 0)
  31.                     {
  32.                         board[i][j].setFillColor(Color.BLACK);
  33.                     } else
  34.                     {
  35.                         board[i][j].setFillColor(Color.WHITE);
  36.                     }
  37.                 } else
  38.                 {
  39.                     if (j%2 != 0)
  40.                     {
  41.                         board[i][j].setFillColor(Color.BLACK);
  42.                     } else
  43.                     {
  44.                         board[i][j].setFillColor(Color.WHITE);
  45.                     }
  46.                 }
  47.             }
  48.         }
  49.     }
  50.    
  51.     public void draw(PApplet drawer)
  52.     {
  53.         for (int y = 0; y < 8; y++)
  54.         {
  55.             for (int x = 0; x < 8; x++)
  56.             {
  57.                 board[y][x].draw(drawer);
  58.             }
  59.         }
  60.     }
  61.    
  62.     public void clicked(int mouseX, int mouseY)
  63.     {
  64.         for (int y = 0; y < 8; y++)
  65.         {
  66.             for (int x = 0; x < 8; x++)
  67.             {
  68.                 if (board[x][y].intersects(mouseX, mouseY))
  69.                 {
  70.                     board[x][y].setFillColor(Color.RED);
  71.                 }
  72.             }
  73.         }
  74.     }
  75.    
  76.     public void move(int pMouseX, int pMouseY)
  77.     {
  78.         if ()
  79.     }
  80.    
  81.     public Tile[][] getBoard()
  82.     {
  83.         return board;
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement