question about java
|
how do you begin making a chess board game in java cuz i really don't have any ideas and the submition is coming in fast |
Re: question about java
Link |
by
on 2005-07-29 14:21:28
|
well, chess has many rules and that is difficult to program. if you dont know where to start, maybe being with a simple game lick checkers. the game of checkers has 3 major components: 1. 2 players 2. many peices 3. the board a rectangular board can be modeled by a 2-d array. each peice can be modeled by a structure containing 4 things: - x coordinate - y coordinate - color of the peice (black/white) - peice size (you can stack peices on top of each other) to draw the chess board, you can make a for loop that counts from 0 up to the number of squares on in the game. for each square, you will draw a horizontal and verticle line that defines the square. to draw the peices, you will need to keep track of them with a data container, like an array or list. you can itterate through the list and draw each peice based on it's properties on top of the board. when a player clicks on a square, game play is handled. here is a sudo-code for the chess game play: if it not your turn, do nothing otherwise, if no piece has been selected, and you have clicked on a piece, select that piece. on the other hand, if a piece is selected, and the place you clicked is an open and legal move, put the piece in the new location and check to see if you have taken any pieces. remove any pieces you took, and also check to see if the game is over. if the game is over, give a congradulations message and reset the peices on the board. let me know if this is helpful or not. :D |
Re: question about java
|
thanks for some ideas on them but i don't know yet how to make a board can anyone help |