Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 17 additions & 24 deletions src/main/java/ChessBoard.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//chess board

import chess.PaintInstruction;

import java.awt.*;
Expand All @@ -17,8 +15,8 @@ public void update(Graphics g) {

public void paint(Graphics g) {
System.err.println("chessboard, paint() being running");
if (vecPaintInstructions.size() == 0) {

boolean NoInstructions= vecPaintInstructions.size() == 0; //refect
if (NoInstructions) {
currentInstruction = new PaintInstruction(0, 0, 8);
vecPaintInstructions.addElement(currentInstruction);

Expand All @@ -27,7 +25,8 @@ public void paint(Graphics g) {
g.setColor(new Color(51, 51, 51));
g.fillRect(50, 450, 450, 50); //Paint over the current status text

for (int i = 0; i < vecPaintInstructions.size(); i++) {
int num_of_PaintInstructions=vecPaintInstructions.size();//refect
for (int i = 0; i <num_of_PaintInstructions; i++) {
currentInstruction = vecPaintInstructions.elementAt(i);
int startRow = currentInstruction.getStartRow();
int startColumn = currentInstruction.getStartColumn();
Expand All @@ -49,24 +48,18 @@ public void paint(Graphics g) {

private void drawTile(int row, int column, Graphics g) {
//todo: add the cell labels A-H:1-8
if ((row + 1) % 2 == 0) {

if ((column + 1) % 2 == 0) {
g.setColor(new Color(255, 255, 255)); //white
} else {
g.setColor(new Color(165, 130, 95)); //black
}

} else {

if ((column + 1) % 2 == 0) {
g.setColor(new Color(165, 130, 95));
} else {
g.setColor(new Color(255, 255, 255));
}

}

boolean RowAndColEven=((row + 1) % 2 == 0)&&((column + 1) % 2 == 0);
boolean RowIsEvenColIsOdd=((row + 1) % 2 == 0)&&((column + 1) % 2 != 0);
boolean RowIsOddColIsEven=((row + 1) % 2 != 0)&&((column + 1) % 2 == 0);
boolean RowAndColOdd=((row + 1) % 2 != 0)&&((column + 1) % 2 != 0);
if(RowAndColEven)
g.setColor(new Color(255, 255, 255));
if(RowIsEvenColIsOdd)
g.setColor(new Color(165, 130, 95));
if(RowIsOddColIsEven)
g.setColor(new Color(165, 130, 95));
if(RowAndColOdd)
g.setColor(new Color(255, 255, 255));
g.fillRect((5 + (column * 50)), (5 + (row * 50)), 50, 50);

}
Expand All @@ -89,4 +82,4 @@ protected int findWhichTileSelected(int coor) //Finds which tile the mouse is ov
return -1;

}
}
}
46 changes: 24 additions & 22 deletions src/main/java/SplashScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,21 @@ public void showSplash() {
JPanel content = (JPanel) getContentPane();
content.setBackground(Color.BLACK);

// Set the window's bounds, centering the window
int width = 500;
int height = 250;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int x = (screen.width - width) / 2;
int y = (screen.height - height) / 2;
setBounds(x, y, width, height);
SetTheWindowBound();
BuildTheSplashScreen(content);
Display(content);
dispose();

// Build the splash screen
JLabel copyrt = new JLabel("***Created by Biraj, Ganesh & Madhav***", JLabel.CENTER);
copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 14));
copyrt.setForeground(Color.WHITE);
content.add(copyrt, BorderLayout.SOUTH);
Color clr = new Color(255, 100, 100);
content.setBorder(BorderFactory.createLineBorder(clr, 5));
}

private void Display(JPanel content) {
JLabel label = new JLabel("", JLabel.CENTER);
content.add(label);
setVisible(true);

for (int i = 0; i < 10; i++) {

label.setIcon(images[i]);


// Display it
label.setVisible(true);

Expand All @@ -56,19 +46,31 @@ public void showSplash() {
Thread.sleep(duration);
} catch (Exception e) {
}

if (i == 9) {
try {
Thread.sleep(5 * duration);
} catch (Exception e) {
}
}

label.setVisible(false);


}
dispose();
}

private void BuildTheSplashScreen(JPanel content) {
JLabel copyrt = new JLabel("***Created by Biraj, Ganesh & Madhav***", JLabel.CENTER);
copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 14));
copyrt.setForeground(Color.WHITE);
content.add(copyrt, BorderLayout.SOUTH);
Color clr = new Color(255, 100, 100);
content.setBorder(BorderFactory.createLineBorder(clr, 5));
}

private void SetTheWindowBound() {
int width = 500;
int height = 250;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int x = (screen.width - width) / 2;
int y = (screen.height - height) / 2;
setBounds(x, y, width, height);
}
}
}