hi codecallers,
overview:
the purpose of this project is to convert chess board expressed in ascii into an opengl window with the chess pieces according to the ascii files
how it works:
all it does is reading the board.txt file that contains the ascii text it must be like this format:
bRk|bKn|bBi|bQu|bKi|bBi|bKn|bRk| ---+---+---+---+---+---+---+--- bP |bP |bP |bP |bP | |bP |bP | ---+---+---+---+---+---+---+--- | | | | | | | | ---+---+---+---+---+---+---+--- | | |wP | |bP | | | ---+---+---+---+---+---+---+--- | | |wQu| | | | | ---+---+---+---+---+---+---+--- | | | | | | | | ---+---+---+---+---+---+---+--- wP |wP |wP | |wP |wP |wP |wP | ---+---+---+---+---+---+---+--- wRk|wKn|wBi| |wKi|wBi|wKn|wRk|-notice the "|" at the end of each line
it reads each line and parses it using the "|" sign and converts the contents (bP ) into an int(-6) that represents the piece
pieces are represented in integers like this:
// -,+ -->black or white // 1,2,3,4,5,6,7 -->piece type, where 1 means empty cell //ex: -2 ==>black knight // 6 ==>white kingthe chess pieces are stored into a 2D array, and in the display function each element(chess piece) is drawn with its attributes(the int value) and according to the int value a specific texture is loaded for it
for(int i=0;i<8;i++)
{
for(int i2=0;i2<8;i2++)
{
element(x,y,board[i][i2]);
x+=5;
}
y-=5;
x=-35;
}
TO DO:
-the black and white cells
-available moves for each piece
-highlighting pieces that are in danger
help?
if anyone can make it better, modify it and post it here. im open for any suggestions or comments
usage:
it works on both windows and linux.
for windows:
you can download the executable and run it perfectly, but place the "board" folder that have the textures in the same place as the exe and the "board.txt" which have the text to be converted
source-code: you can open the project with devcpp using the project file in the attached files, make sure you have the glut package installed
for linux:
-you can compile it by opening the directory that has the project in it "cd asciichess" then make "make" to compile the files. the you can run it from the generated executable called "asciichess"
screenshots:
http://forum.codecal...=1&d=1241501539


Sign In
Create Account




Back to top










