Skip to content

Commit

Permalink
Fixed issue with references not updating intercepters in the vector a…
Browse files Browse the repository at this point in the history
…nd fixed interceptor horizontal movement.
  • Loading branch information
ejatgit committed May 27, 2024
1 parent bc4aa2b commit c5e97f1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 27 deletions.
32 changes: 16 additions & 16 deletions CPP/High_Voltage/mFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int interceptorColumnOffset(int iValue) {
//If iTest > 0 Then
if (iTest > 0) {
// interceptorColumnOffset = 1
return 0;
return 1;
}
//ElseIf iTest < 0 Then
else if (iTest < 0) {
Expand Down Expand Up @@ -143,37 +143,37 @@ void Output_A_Message(std::string sNowMessage,std::string rLocation) {
//write out to the console some where
if (rLocation == "nMsgbox0")
{
csbiInfo.dwCursorPosition.X = 0;
csbiInfo.dwCursorPosition.Y = iMazeRows + 2;
SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
// csbiInfo.dwCursorPosition.X = 0;
// csbiInfo.dwCursorPosition.Y = iMazeRows + 2;
// SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
std::cout << sNowMessage << std::endl;
}
else if (rLocation == "nMsgBox1")
{
csbiInfo.dwCursorPosition.X = 0;
csbiInfo.dwCursorPosition.Y = iMazeRows + 3;
SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
// csbiInfo.dwCursorPosition.X = 0;
// csbiInfo.dwCursorPosition.Y = iMazeRows + 3;
//SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
std::cout << sNowMessage << std::endl;
}
else if (rLocation == "nInterAlive")
{
csbiInfo.dwCursorPosition.X = 0;
csbiInfo.dwCursorPosition.Y = iMazeRows + 4;
SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
//csbiInfo.dwCursorPosition.X = 0;
//csbiInfo.dwCursorPosition.Y = iMazeRows + 4;
//SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
std::cout << sNowMessage << std::endl;
}
else if (rLocation == "nInterKilled")
{
csbiInfo.dwCursorPosition.X = 0;
csbiInfo.dwCursorPosition.Y = iMazeRows + 5;
SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
//csbiInfo.dwCursorPosition.X = 0;
//csbiInfo.dwCursorPosition.Y = iMazeRows + 5;
//SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
std::cout << sNowMessage << std::endl;
}
else if (rLocation == "nTotalinterceptorsKilled")
{
csbiInfo.dwCursorPosition.X = 0;
csbiInfo.dwCursorPosition.Y = iMazeRows + 6;
SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
//csbiInfo.dwCursorPosition.X = 0;
//csbiInfo.dwCursorPosition.Y = iMazeRows + 6;
//SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
std::cout << sNowMessage << std::endl;
}

Expand Down
29 changes: 18 additions & 11 deletions CPP/High_Voltage/mMoveCharacters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,36 +86,41 @@ void MoveInterceptors(){
//std::cerr << "Number of Interceptors: " + interceptorCollection.size();
//for (int i = 0; i < interceptorCollection.Count(); ++i) {
for (int i = 0; i < interceptorCollection.size(); ++i) {
cInterceptor cNowInterceptor = interceptorCollection[i];
// cInterceptor cNowInterceptor = interceptorCollection[i];
// If cNowinterceptor.Alive Then

if (cNowInterceptor.Alive() == true) {
if (interceptorCollection[i].Alive() == true) {
// iLastRow = cNowinterceptor.Row
iLastRow = cNowInterceptor.Row();
iLastRow = interceptorCollection[i].Row();
// iLastColumn = cNowinterceptor.Column
iLastColumn = cNowInterceptor.Column();
iLastColumn = interceptorCollection[i].Column();
//
// cNowinterceptor.Row = cNowinterceptor.Row + interceptorRowOffset(cNowinterceptor.Row)
cNowInterceptor.Row(cNowInterceptor.Row() + interceptorRowOffset(cNowInterceptor.Row()));
// cNowInterceptor.Row(cNowInterceptor.Row() + interceptorRowOffset(cNowInterceptor.Row()));
interceptorCollection[i].Row(interceptorCollection[i].Row() + interceptorRowOffset(interceptorCollection[i].Row()));
// cNowinterceptor.Column = cNowinterceptor.Column + interceptorColumnOffset(cNowinterceptor.Column)
cNowInterceptor.Column(cNowInterceptor.Column() + interceptorColumnOffset(cNowInterceptor.Column()));
// cNowInterceptor.Column(cNowInterceptor.Column() + interceptorColumnOffset(cNowInterceptor.Column()));
interceptorCollection[i].Column(interceptorCollection[i].Column() + interceptorColumnOffset(interceptorCollection[i].Column()));
//
// sTargetChar = rMaze.Cells(cNowinterceptor.Row, cNowinterceptor.Column).Value
sTargetChar = rMaze[cNowInterceptor.Row()][cNowInterceptor.Column()];
//sTargetChar = rMaze[cNowInterceptor.Row()][cNowInterceptor.Column()];
sTargetChar = rMaze[interceptorCollection[i].Row()][interceptorCollection[i].Column()];
//
// If sTargetChar = sOpenAreaSymbol Then
if (sTargetChar == sOpenAreaSymbol) {
// rMaze.Cells(iLastRow, iLastColumn).Value = sOpenAreaSymbol
rMaze[iLastRow][iLastColumn] = sOpenAreaSymbol;
// rMaze.Cells(cNowinterceptor.Row, cNowinterceptor.Column).Value = sinterceptorSymbol
rMaze[cNowInterceptor.Row()][cNowInterceptor.Column()] = sInterceptorSymbol;
// rMaze[cNowInterceptor.Row()][cNowInterceptor.Column()] = sInterceptorSymbol;
rMaze[interceptorCollection[i].Row()][interceptorCollection[i].Column()] = sInterceptorSymbol;
}
// ElseIf sTargetChar = sPlayerSymbol Then
else if (sTargetChar == sPlayerSymbol) {
// rMaze.Cells(iLastRow, iLastColumn).Value = sOpenAreaSymbol
rMaze[iLastRow][iLastColumn] = sOpenAreaSymbol;
// rMaze.Cells(cNowinterceptor.Row, cNowinterceptor.Column).Value = sDeadPlayerSymbol
rMaze[cNowInterceptor.Row()][cNowInterceptor.Column()] = sDeadPlayerSymbol;
//rMaze[cNowInterceptor.Row()][cNowInterceptor.Column()] = sDeadPlayerSymbol;
rMaze[interceptorCollection[i].Row()][interceptorCollection[i].Column()] = sDeadPlayerSymbol;
// iPlayerDeaths = iPlayerDeaths + 1
iPlayerDeaths = iPlayerDeaths + 1;
// cActivePlayer.Alive = False
Expand All @@ -127,12 +132,14 @@ void MoveInterceptors(){
// iDeaths = iDeaths + 1
iDeaths = iDeaths + 1;
// cNowinterceptor.Alive = False
cNowInterceptor.Alive(false);
//cNowInterceptor.Alive(false);
interceptorCollection[i].Alive(false);
// End If
}
else {
rMaze[iLastRow][iLastColumn] = sOpenAreaSymbol;
rMaze[cNowInterceptor.Row()][cNowInterceptor.Column()] = sInterceptorSymbol;
//rMaze[cNowInterceptor.Row()][cNowInterceptor.Column()] = sInterceptorSymbol;
rMaze[interceptorCollection[i].Row()][interceptorCollection[i].Column()] = sInterceptorSymbol;
}
// End If
}
Expand Down

0 comments on commit c5e97f1

Please sign in to comment.