I need help with a small game! C++
Wo1ves1n0 (5)

So, I am working on a game for my assignment which I'm trying to keep simple. However, I'm getting confused watching people teach me how to do it.

The game is about a story that involves combat/Adventure. (More info about this please let me know.)
So I need to add like a betting game. So the player bets a number to 50, then the enemy will bet. and if the player wins the bet they continue, but if they lose I will add a loop of corruption to add a death kind of code haha. however, I want to add like a checkpoint to that section rather them having to do it all over again. if anyone knows how to do it please let me know!

Thanks!

You are viewing a single comment. View All
SPQR (375)

Maybe have a do/while or a while loop start at that section, and have the condition be while the player hasn't won, or something like that. So, you could have code looking something like this:

bool won = false;
bool continue = false;

while (won == false)  /*(!won would work too I think)*/
{

  do
  {

      /*You can put your actual gambling game code here, I can help you with that too if you'd like*/
    if (/*The game is done*/) {continue = true;}

  }
  while (continue == false) /*This is your game loop for your minigame thing*/

  if (won == false)
  {
    gameOver(); /*You'd make something like this your game over function, making it a function will help you later*/
  }

}

/*If the player wins it'll continue*/

If you want me to actually go in depth with this and help some more reply to this, I'll see it pretty fast :P

SPQR (375)

Also, repl.it has this handy feature dubbed "multiplayer" which allows people to collaborate in real time, so if you want to do that so I can actually teach u stuff I'd be down, I've got time

Wo1ves1n0 (5)

@SPQR So this is my code at the moment
#include <iostream>
using namespace std;

int main() { //Start of the game
////////////////////////////////////////////////////////////////////////////////////////////
string name; //Players name
int go; //Telling the player to start the game
////////////////////////////////////////////////////////////////////////////////////////////
cout << "'What are you doing here? You're not suppose to be here. Oh no, this must be a mistake. Well I guess we are going to have to help you escape.'" << endl; //(Jack speaking) start of the story.

cout << " " << endl; // Space
////////////////////////////////////////////////////////////////////////////////////////////

cout << "'Sorry, Names Jack. I've been here for almost a decade, learnt parts of the system that has came to curruption. It has taken over half the system. its dangerous. I need to know things about you. Tell me your name?'" << endl; //Part 1

cout << " " << endl; //Space
////////////////////////////////////////////////////////////////////////////////////////////
cout << "Enter Your Name: " << endl; //User asked to Enter name
cin >> name; //Input name
cout << " " << endl; //Space

////////////////////////////////////////////////////////////////////////////////////////////
cout << "'That's your name? " << name << "? " << "Ok no time to be scarcastic. But that name sounds dramatic as hell! Anyways. Nice to meet you. First things first we need to follow the circut to the main port. Its going to be dangrous but its the only way. Let's go " << name << "!'" << endl; //Part 1.2
cout << " " << endl;//Space

cout << "Type 'go' to walk towards the main port to start your escape!" << endl; //Telling the users to start the walk
cout << " " << endl;//Space
cin >> go;//Input for the user to start walking.
cout << " " << endl;//Space
cout << "You and jack start to take a walk through the circut. Its cold, dark and closure. You look in the far distance and see a smoky figure, as your mind wonders curiosity if that 'thing' is real? You have a choice, would you like to go and talk to the black figure? or bypass it? " << endl; //First decision. Part 1.3
////////////////////////////////////////////////////////////////////////////////////////////

}//End of the story.

Shall I continue that under the brackets? But this means he can continue and if he doesn't talk to the black figure how do I make 2 sperate stroys to keep it simple.

SPQR (375)

@Wo1ves1n0 The program will run only what's in int main() {}, so anything you want to run will have to be inside those brackets or linked to those brackets via functions. For making the two separate stories, you could use an if statement and go from there. As for what the simplest way of doing things is, though, it really depends on where you want the story to go. If you could conjure up a basic storyboard type thing it'd be helpful. Also, I can actually get in depth with helping you if you add me to a multiplayer session if you'd like.

Wo1ves1n0 (5)

@SPQR Ok will do that right now