Skip to content

Commit

Permalink
Added intro, got missing messages to show up, added play again featur…
Browse files Browse the repository at this point in the history
…e, got rand to be more random.
  • Loading branch information
ejatgit committed May 27, 2024
1 parent c5e97f1 commit 5579f3a
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CPP/High_Voltage/mBuildMaze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void SpawnPlayer(){
//iCount = 1
//
//Do
srand(time(NULL));
for (int iCount = 0; iCount < 1000; ++iCount) {
// iRow = Int(((rMaze.Rows.Count - 1) * Rnd) + 2)
int iRow = ((rand() % (iMazeRows - 1)) + 2);
Expand Down Expand Up @@ -56,6 +57,7 @@ void Spawninterceptors() {
//

//For i = 1 To iNumberOfinterceptors
srand(time(NULL));
for (int i = 0; i < iNumberOfinterceptors; ++i) {
// iCount = 1
// Set cNowinterceptor = New cInterceptor
Expand Down Expand Up @@ -109,6 +111,7 @@ void InstallHighVoltageBarriers(){
int iDice;
//
//For iRow = 1 To rMaze.Rows.Count
srand(time(NULL));
for (int iRow = 0; iRow < iMazeRows; ++iRow) {
// iBarrierCount = 0
iBarrierCount = 0;
Expand Down
11 changes: 6 additions & 5 deletions CPP/High_Voltage/mController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
bool UnLoadMe{};

void mController_Show() {
Output_A_Message("Make your move: ", "MsgBox0");
Output_A_Message("Make your move: ", "nMsgBox0");
UnLoadMe = false;
std::string sNowInput{ "" };
do
Expand Down Expand Up @@ -60,17 +60,18 @@ void mController_Show() {
else
{
//do nothing
Output_A_Message("I don't understand.", "MsgBox0");
Output_A_Message("I don't understand.", "nMsgBox0");
}
} while (UnLoadMe == false);
}



void CommandButton0_Click() {
srand(time(NULL));
int iRow{ ((rand() % iMazeRows) + 1) - Shared_Vars::cActivePlayer.Row()};
int iColumn{ ((rand() % iMazeCols) + 1) - Shared_Vars::cActivePlayer.Column()};
Output_A_Message("Super Jump!!!", "MsgBox0");
Output_A_Message("Super Jump!!!", "nMsgBox0");
MovePlayer(iRow, iColumn);
MoveInterceptors();
WhoIsAlive();
Expand Down Expand Up @@ -138,12 +139,12 @@ void CommandButtonExit_Click(){
void WhoIsAlive(){
DrawTheMaze();
if (Shared_Vars::cActivePlayer.Alive() == false) {
Output_A_Message("You are dead. You lose.", "nMsgbox2");
Output_A_Message("You are dead. You lose.", "nMsgBox2");
//Call Unload(Me)
UnLoadMe = true;
}
else if (CheckInterceptorsAlive() == false) {
Output_A_Message("All the interceptors are dead. You win.", "nMsgbox2");
Output_A_Message("All the interceptors are dead. You win.", "nMsgBox2");
//Call Unload(Me)
UnLoadMe = true;
}
Expand Down
39 changes: 35 additions & 4 deletions CPP/High_Voltage/mFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ bool CheckInterceptorsAlive() {

void Output_A_Message(std::string sNowMessage,std::string rLocation) {
//write out to the console some where
if (rLocation == "nMsgbox0")
if (rLocation == "nMsgBox0")
{
// csbiInfo.dwCursorPosition.X = 0;
// csbiInfo.dwCursorPosition.Y = iMazeRows + 2;
Expand All @@ -155,28 +155,59 @@ void Output_A_Message(std::string sNowMessage,std::string rLocation) {
//SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
std::cout << sNowMessage << std::endl;
}
else if (rLocation == "nMsgBox2")
{
// csbiInfo.dwCursorPosition.X = 0;
// csbiInfo.dwCursorPosition.Y = iMazeRows + 4;
//SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
std::cout << sNowMessage << std::endl;
}
else if (rLocation == "nInterAlive")
{
//csbiInfo.dwCursorPosition.X = 0;
//csbiInfo.dwCursorPosition.Y = iMazeRows + 4;
//csbiInfo.dwCursorPosition.Y = iMazeRows + 5;
//SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
std::cout << sNowMessage << std::endl;
}
else if (rLocation == "nInterKilled")
{
//csbiInfo.dwCursorPosition.X = 0;
//csbiInfo.dwCursorPosition.Y = iMazeRows + 5;
//csbiInfo.dwCursorPosition.Y = iMazeRows + 6;
//SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
std::cout << sNowMessage << std::endl;
}
else if (rLocation == "nTotalinterceptorsKilled")
{
//csbiInfo.dwCursorPosition.X = 0;
//csbiInfo.dwCursorPosition.Y = iMazeRows + 6;
//csbiInfo.dwCursorPosition.Y = iMazeRows + 7;
//SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
std::cout << sNowMessage << std::endl;
}

}
bool PlayAGame() {
std::string sResponse;
Output_A_Message("Do you want to play a game (Y or N)? ", "nMsgBox0");
std::cin >> sResponse;
std::string sLeftChar = sResponse.substr(0,1);
if (sLeftChar == "Y" || sLeftChar == "y") {
return true;
}
else {
return false;
}
}
bool PlayAgain() {
std::string sResponse;
Output_A_Message("Do you want to play again (Y or N)? ", "nMsgBox0");
std::cin >> sResponse;
std::string sLeftChar = sResponse.substr(0, 1);
if (sLeftChar == "Y" || sLeftChar == "y") {
return true;
}
else {
return false;
}
}


2 changes: 2 additions & 0 deletions CPP/High_Voltage/mFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ int interceptorRowOffset(int iValue);
int interceptorColumnOffset(int iValue);
bool CheckInterceptorsAlive();
void Output_A_Message(std::string sNowMessage, std::string rLocation);
bool PlayAGame();
bool PlayAgain();
#endif

6 changes: 3 additions & 3 deletions CPP/High_Voltage/mMoveCharacters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void MovePlayer(int x_iRow, int x_iColumn) {
rMaze[cActivePlayer.Row()][cActivePlayer.Column()] = sDeadPlayerSymbol;
// 'MsgBox "You hit an interceptor!"
// Range("nMsgbox1").Value = "You hit an interceptor!"
Output_A_Message("You hit an interceptor!","MsgBox0");
Output_A_Message("You hit an interceptor!","nMsgBox0");
//
cActivePlayer.Alive(false);
}
Expand All @@ -56,7 +56,7 @@ void MovePlayer(int x_iRow, int x_iColumn) {
rMaze[cActivePlayer.Row()][cActivePlayer.Column()] = sDeadPlayerSymbol;
// 'MsgBox "You hit a barrier!"
// Range("nMsgbox1").Value = "You hit a barrier!"
Output_A_Message("You hit a barrier!","MsgBox0");
Output_A_Message("You hit a barrier!","nMsgBox0");
// cActivePlayer.Alive = False
cActivePlayer.Alive(false);
//End If
Expand Down Expand Up @@ -167,7 +167,7 @@ void MoveInterceptors(){
if (iPlayerDeaths > 0) {
// 'MsgBox "You've been hit by " & iPlayerDeaths & " interceptor(s)!"
// Range("nMsgbox0").Value = "You've been hit by " & iPlayerDeaths & " interceptor(s)!"
Output_A_Message("You've been hit by " + std::to_string(iPlayerDeaths) + " interceptor(s)!", "nMsgbox0");
Output_A_Message("You've been hit by " + std::to_string(iPlayerDeaths) + " interceptor(s)!", "nMsgBox0");
//End If
} //
//End Sub
Expand Down
39 changes: 34 additions & 5 deletions CPP/High_Voltage/mRunGame.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
#include"mRunGame.h"
#include"mBuildMaze.h"
#include"mController.h"
#include"mFunctions.h"
//#include"High_Voltage.h"
//Attribute VB_Name = "mRunGame"
//Option Explicit
//
void RunGame() {
//Sub RunGame()
//
//Call InitialFillMaze
InitialFillMaze();
//frmController.Show
mController_Show();
//Call ExitGame
GameIntro();
if (PlayAGame() == true) {
//Call InitialFillMaze
InitialFillMaze();
//frmController.Show
mController_Show();
//Call ExitGame
}
if (PlayAgain() == true) {
do
{
InitialFillMaze();
mController_Show();
} while (PlayAgain() == true);
}
ExitGame();
//
//End Sub
Expand All @@ -27,4 +38,22 @@ void ExitGame(){
//Set rMaze = Nothing
//
//End Sub
}
void GameIntro() {
Output_A_Message("You are within the walls of a high voltage maze.", "nMsgBox0");
Output_A_Message("There are 15 security machines trying to destroy you.", "nMsgBox0");
Output_A_Message("You are the '*' the interceptors are the '+'.", "nMsgBox0");
Output_A_Message("The areas marked 'x' are high voltage.", "nMsgBox0");
Output_A_Message("Your only hope is to destroy the interceptors by", "nMsgBox0");
Output_A_Message("running them into an 'x'. ----So Long Turkey!!!----", "nMsgBox0");
Output_A_Message("moves are as follows : ", "nMsgBox0");
Output_A_Message("7.8.9", "nMsgBox0");
Output_A_Message("4. .6", "nMsgBox0");
Output_A_Message("1.2.3", "nMsgBox0");
Output_A_Message(" ", "nMsgBox0");
Output_A_Message("5 = No move for one turn.", "nMsgBox0");
Output_A_Message("10 = No move for the rest of the game.", "nMsgBox0");
Output_A_Message("-1 = Give up.Situation hopeless.", "nMsgBox0");
Output_A_Message("and of course '0' is super jump.", "nMsgBox0");

}
1 change: 1 addition & 0 deletions CPP/High_Voltage/mRunGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
//#include"GlobalVariables.h"

void RunGame();
void GameIntro();
void ExitGame();
#endif

0 comments on commit 5579f3a

Please sign in to comment.