/* Date started: *01/09/2005 History: *V0.2 I first started by making the GUI and chess board. Origionally the GUI was going to have a lblStatus, to display information such as player turn, error messages etc. I designed the chess board by using for loops and starting X and Y values. *V0.5 I plan to use a 2D array 8*8 to represent the board, with the value of each cell representing the contents of the corrosponding board tile. I created the default matrix with all the pieces set up, and found a problem. The pieces were set up on the west and east sides of the board. The problem was, in the array, [row] is the up/down position. In painting, X is the left/right position. So when painting, X is column, Y is row. *V0.8 I was going to use the coins from my previous connect4 programme, but they are 25*25 pixels and so positioning them in the centre of a tile would be difficult, plus they are not transparent. I created 50*50 pixel picture with a black circle, then using photoshop, saved 4 copies with the circle either red or blue, and with or without a K in it. I made the background transparent so the board shows through the blank parts of the image. *V1.0 At this point I was wondering how to do the rules, first I planned to have a rules object that the cellMatrix called. Then I thought that the rules object needs the cellMatrix, not the cellMatrix needs the rules, but also the draughts board needs the cellMatrix. The solution was for the rules object to extend the cellMatrix. *V1.2 I started programming the rules, such as bunny hopping, how pieces can move, which direction they can move in etc. I used a mouse listener with the draughts board to find which tile had been selected, then caught the next click for the intended destination. Most of the rules compare the destination with the source, to check the piece can move there, if it involves hopping over an enemy etc. *V1.4 I had a few problems with index out of range errors with the arrays. After fixing these problems the game was working, pieces could move and take over other pieces. I added a checker to find if any enemy pieces still existed on the board, and a little code that changes the normal piece into a king when it reaches the end of the board. *V1.6 After thinking about how I extended the cellMatrix, I thought about the chess board. The chess board is a standard template for draughts, chess etc, so I decided to make it into an object that can be extended. I moved all the code relating to a chess board to draughtsChessBoard and added a method called drawExtra, which allows the class extending it to draw extra features like player pieces, messages etc. At first I had a problem with the board drawing but not the pieces, I discovered this was because I used private, I had to use protected. *V2.0 Some people complained, saying normal pieces can not move backwards even when bunny hopping, so I have removed this. Normal pieces can only bunny hop in their normal direction, kings can bunny hop in any direction. Plans: *Make AI */ //GUI and main programme import java.awt.*; import java.awt.event.*; import javax.swing.*; public class draughts extends JApplet implements ActionListener { private draughtsCanvas draughtsBoard; private JButton cmdNewGame; private Container frame; private JPanel panBoard, panStatusArea, panButton; private Color clrBackgrounds; public void init() { draughtsBoard = new draughtsCanvas(); try { Image coinRed = dataManager.createImage(this, getParameter("coinRed")); Image coinBlue = dataManager.createImage(this, getParameter("coinBlue")); Image coinRedKing = dataManager.createImage(this, getParameter("coinRedKing")); Image coinBlueKing = dataManager.createImage(this, getParameter("coinBlueKing")); draughtsBoard.setupCoins(coinRed, coinBlue, coinRedKing, coinBlueKing); } catch (Exception e) { } draughtsBoard.setSize(new Dimension(500,500)); cmdNewGame = new JButton("New Game"); cmdNewGame.addActionListener(this); frame = getContentPane(); panBoard = new JPanel(); panButton = new JPanel(); frame.add(panBoard, BorderLayout.NORTH); panBoard.add(draughtsBoard); frame.add(panButton, BorderLayout.SOUTH); panButton.add(cmdNewGame); clrBackgrounds = new Color(75,141,221); frame.setBackground(clrBackgrounds); panBoard.setBackground(clrBackgrounds); panButton.setBackground(clrBackgrounds); } public void actionPerformed(ActionEvent e) { draughtsBoard.resetBoard(); } }