mirror of
				https://github.com/lov3b/Schack.git
				synced 2025-11-03 22:50:24 +01:00 
			
		
		
		
	Love suger på att lägga till repaint
This commit is contained in:
		@@ -30,10 +30,10 @@ public class Board extends JPanel implements MouseListener {
 | 
				
			|||||||
    private Piece[][] initPieces() throws IOException {
 | 
					    private Piece[][] initPieces() throws IOException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Piece[][] piecesRet = {
 | 
					        Piece[][] piecesRet = {
 | 
				
			||||||
            {new Rook(false, new Point(0, 0)), null, null, null, null, null, null, new Rook(true, new Point(0, 7))},
 | 
					            {new Rook(false, new Point(0, 0)), null, null, new Pawn(false, new Point(0,4)), null, null, null, new Rook(true, new Point(0, 7))},
 | 
				
			||||||
            {new Horse(false, true, new Point(1, 0)), null, null, null, null, null, null, new Horse(true, true, new Point(1, 7))},
 | 
					            {new Horse(false, true, new Point(1, 0)), null, null, null, null, null, null, new Horse(true, true, new Point(1, 7))},
 | 
				
			||||||
            {new Bishop(false, new Point(2, 0)), null, null, null, null, null, null, new Bishop(true, new Point(2, 7))},
 | 
					            {new Bishop(false, new Point(2, 0)), null, null, null, null, null, null, new Bishop(true, new Point(2, 7))},
 | 
				
			||||||
            {new Queen(false, new Point(3, 0)), null, null, null, new Queen(false, new Point(3, 4)), null, null, new Queen(true, new Point(3, 7))},
 | 
					            {new Queen(false, new Point(3, 0)), null, null, null, new Pawn(false, new Point(3, 4)), null, null, new Queen(true, new Point(3, 7))},
 | 
				
			||||||
            {new King(false), null, null, null, null, null, null, new King(true)},
 | 
					            {new King(false), null, null, null, null, null, null, new King(true)},
 | 
				
			||||||
            {null, null, null, null, null, null, null, new King(false, new Point(5, 7))},
 | 
					            {null, null, null, null, null, null, null, new King(false, new Point(5, 7))},
 | 
				
			||||||
            {null, null, null, null, null, null, null, null},
 | 
					            {null, null, null, null, null, null, null, null},
 | 
				
			||||||
@@ -197,6 +197,7 @@ public class Board extends JPanel implements MouseListener {
 | 
				
			|||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            validMovesToDraw.clear();
 | 
					            validMovesToDraw.clear();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					       getParent().repaint();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,7 @@ import javax.swing.UIManager;
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author Love Billenius & Simon Hansson
 | 
					 * @author Love Billenius & Simon Hansson
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class Schack extends JFrame implements Runnable {
 | 
					public class Schack extends JFrame{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Schack() throws IOException {
 | 
					    public Schack() throws IOException {
 | 
				
			||||||
        setTitle("Schack");
 | 
					        setTitle("Schack");
 | 
				
			||||||
@@ -26,7 +26,7 @@ public class Schack extends JFrame implements Runnable {
 | 
				
			|||||||
        Board board = new Board();
 | 
					        Board board = new Board();
 | 
				
			||||||
        setContentPane(board);
 | 
					        setContentPane(board);
 | 
				
			||||||
        getContentPane().addMouseListener(board);
 | 
					        getContentPane().addMouseListener(board);
 | 
				
			||||||
        Thread thread = new Thread(this);
 | 
					      
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Set theme
 | 
					        // Set theme
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
@@ -74,7 +74,7 @@ public class Schack extends JFrame implements Runnable {
 | 
				
			|||||||
        pack();
 | 
					        pack();
 | 
				
			||||||
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 | 
					        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 | 
				
			||||||
        setVisible(true);
 | 
					        setVisible(true);
 | 
				
			||||||
        this.run();
 | 
					        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -83,18 +83,6 @@ public class Schack extends JFrame implements Runnable {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public void run() {
 | 
					 | 
				
			||||||
   
 | 
					   
 | 
				
			||||||
        while (true) {
 | 
					 | 
				
			||||||
            try {
 | 
					 | 
				
			||||||
                Thread.sleep(12);
 | 
					 | 
				
			||||||
            } catch (InterruptedException ex) {
 | 
					 | 
				
			||||||
                Logger.getLogger(Schack.class.getName()).log(Level.SEVERE, null, ex);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            repaint();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
   
 | 
					   
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user