|
-
October 31st, 2003, 04:34 AM
#1
Alright i cant edit my post so here is a new one...i think i found your error. if you go to TestGame.cpp and look at this bit of code:
Code:
if (color == 'b')
{
cout << "Enter your move (rowcolumn) a-h|1-8:: ";
cin >> currentMove;
//changes letters to numbers
if (currentMove[0] == 'a')
{
move.row = '1';
}
if (currentMove[0] == 'b')
{
move.row = '2';
}
if (currentMove[0] == 'c')
{
move.row = '3';
}
//etc...
Notice this comment in your code:
//changes letters to numbers
That isnt correct, it doesnt change letters to numbers, although thats what it looks like it is doing. it is just chaing letters to other letters. both 'a' and '1' are two different characters, '1' isnt an integer. Alright, so that compiled fine cause a character can be transformed into an integer (buts thats not what you wanted). Anyways, you then went on and wrote this line of code:
gameBoard->EnterMove(gameBoard, move.row, move.column, 'b');
The problem with that line is that move.row is not taking in an integer, as it should do, but instead it is taking in a character. If you look bellow you will see the problem this will create...
Now look at your function void EnterMove(BoardRecord *gameBoard, int pRow, char pCol, char pPieceColor) in BoardClass.cpp
ok damn this is a bitch to explain online...well look at your function's signature...like i said above, you typed gameBoard->EnterMove(gameBoard, move.row, move.column, 'b'). move.row is suppose to match up with int pRow, therefore the character '1' gets transformed into its ANSII value which is 49. look at your code bellow sorry this post is taking so much room...please bear with me:
Code:
Row = pRow;
Col = pCol;
PieceColor = pPieceColor;
if (PieceColor == 'b')
{
cout << "Piece Color is: " << PieceColor << "\n\n";
gameBoard->Board[Row].Rows[Col].Piece = PieceColor;
}
So lets just look at this code...your variable Row now contains the integer 49 NOT 1 like you wanted it to. Then on your last line of code in this little quote thing is gameBoard->Board[Row].Rows[Col].Piece = PieceColor; Well the problem here is that Row contains 49 NOT 1.
Alright so basically you are mixing integers with characters by trying to preform your char/int combo thing. When you assign a character value to a variable that is suppose to hold an integer, the variable will take the ANSII value of that character and hold it. Anyways i hope this solves your problem...let me know if you need more help 
Well just a 15 year old's 2 cents...
Support your right to arm bears.

^^This was the first video game which i played on an old win3.1 box
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|