i'm building a basic chess program. i set up a class to define each chess piece.
this class contains all the information needed to set up a chess piece and define its location on the board.
the location is stored in the class.
what would be fantastic is if anybody could tell me how to select each piece knowing only its location on the chessgrid.
thanks
heres the class definition.
Code:
class piece
{
public:
//Constructors
piece(char side, char type, int y, int x);
//Purpose: to set a piece and declare its initial location and type.
//Parameters: init piece type (caps for white), init piece location
//Detectors
void piece::allowed_moves(char board[8][8]);
//Purpose: based on the location of a piece, the present state of the board and
// the piece type, this calculates the allowable moves for that piece.
//Parameters: type of piece, present location, present board state, alowed moves.
void request_move( int y, int x);
//Purpose: allow the user to select a move from a couple of those already defined.
//Perameters: x, y coordinates.
char piece_typer();
//Purpose: return the piece type info
//Returns: piece_type.
int side_return();
//Purpose: return the piece side as an integer
//Returns: -1 for black 1 for white.
//Mutators
void place(char board[8][8]);
//Purpose: place a piece on the chess board.
//Parameters: chessboard array.
void move(int y, int x, char board[8][8]);
//Purpose: given a piece location set a new defined location based on allowed moves.
//Parameters: piece location.
void kill(char board[8][8]);
//Purpose: delete the piece.
private:
void move_check (int g, int h, int a, int b, char c[8][8]);
char piece_type, piece_side;
int location;
int sider;
int allowed[8][8];
};