Saving Scores & What Not...

Started by
2 comments, last by NUCLEAR RABBIT 18 years ago
Hello, I wanted to Make it possible for the user to Play my little Game and be able to save their scores. Is it possible to do this with my Game? NOTE: Im still learning, so its in the command promt.
// Computer picks a number & user tries to guess
// Guess My Digits

#include <string>
#include <iostream>
#include <ctime>
#include <windows.h>
#include <cstdlib>
using namespace std;

//Declaire Variables
    int menuSelection = 0;
    int loopCount = 0;
    int myNumber = 0;
    int guess = 0;
    int compNumber = 0;
    int comp = 0;
    int startScore = 100;
    int score;
    const short POINT_LOSS = 10;
    



int menu(int& option)
{
        cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n"
             << "&&                                         &&\n"
             << "&&   Welcome to, Guess My Number, Bitch!   &&\n"
             << "&&            By: Brandon Wall             &&\n"
             << "&&                                         &&\n"
             << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n\n"
             << "++ Please Select An Option ++\n"
             << "1. Im Feeling Lucky!\n"
             << "2. Im More of A Slave Driver...\n\n"
             << "Your Choice: ";
        cin >> option;
}

int gameLoop()
{
    
    
    //Executes The Menu Function
    menu(menuSelection);
    
    //Game Begins
    if(menuSelection == 1)
    {
            //Clears Screen
            system("cls");
            
            //Instructions
            cout << "So You're Feelin' Lucky, aye? Well, We'll See..."
                 << "Below Is the Game Rules. Please follow them or Your time"
                 << "well be up! Have Fun!\n\n"
                 << "*************************\n"
                 << "**                     **\n"
                 << "**     Game Rules:     **\n"
                 << "**                     **\n"
                 << "*************************\n\n"
                 << "1) Try To Guess The King's Number, but keep The Numbers\n"
                 << "Between 1-50.\n"
                 << "2) Try And Use the Least Number of Guesses for Max. Points.\n\n";
                 
            //Waits for user to cont.
            system("pause");
            system("cls");
            
            //Computer gets his number
            cout << "Please Wait while The King Pick's Number.\n\n"
                 << "P";
                 Sleep(1000);
            cout << "I";
                 Sleep(1000);
            cout << "C";
                 Sleep(1000);
            cout << "K";
                 Sleep(1000);
            cout << "I";
                 Sleep(1000);
            cout << "N";
                 Sleep(1000);
            cout << "G";
                 Sleep(1000);
            cout << "\n\nThe King: Ok, I've Got it.";
                 Sleep(2000);
            
            //Clears Screen For Guessing
            system("CLS");
    }
    else
    {
          std::cout << "\n\nOk, Do that Somewhere Else, BYE!";
    }

}

int guessing()
{
            
            //Guessing Begins
            cout << "The King: Ok Peasant, Get To Guessing!\n"
                 << "Good Luck! Wuhahahaha!\n\n"
                 << "Your Guess: ";
            cin >> guess;
            
            //Checking Numbers!
            while(guess > compNumber)
            {
                     //Add Start counting number loops
                     loopCount += 1;
                     
                     cout << "The King: Nope, Thats Too High!";
                          Sleep(1000);
                          system("cls");
                     cout << "Your New Guess: ";
                     cin >> guess;
                     continue;
            
            while(guess < compNumber)
            {
                     //Add Start counting number loops
                     loopCount += 1;
                     
                     cout << "The King: Nope, Thats Too Low!";
                          Sleep(1000);
                          system("cls");
                     cout << "Your New Guess: ";
                     cin >> guess;
                     continue;
            }
            if(guess == compNumber)
            {
                     //Formula for Getting Score
                     score = startScore - (loopCount * POINT_LOSS);
                     
                     //Puts Good Job Greeting
                     cout << "\n\nThe King: AHH! Good Jorb, My Gimp!\n"
                          << "Heres Your Game Stats:\n\n"
                          << "Number Of Guesses: "
                          << loopCount << endl
                          << "Score: "
                          << score << endl
                          << "Good Job, Ol' Chap! Bye Bye!\n\n";
                     system("pause");
                     break;
            }
    }
            //Checking Numbers!
            while(guess < compNumber)
            {
                     //Add Start counting number loops
                     loopCount += 1;
                     
                     cout << "The King: Nope, Thats Too Low!";
                          Sleep(1000);
                          system("cls");
                     cout << "Your New Guess: ";
                     cin >> guess;
                     
            
            while(guess > compNumber)
            {
                     //Add Start counting number loops
                     loopCount += 1;
                     
                     cout << "The King: Nope, Thats Too High!";
                          Sleep(1000);
                          system("cls");
                     cout << "Your New Guess: ";
                     cin >> guess;
            }
            while(guess == compNumber)
            {
                     //Formula for Getting Score
                     score = startScore - (loopCount * POINT_LOSS);
                     
                     //Puts Good Job Greeting
                     cout << "\n\nThe King: AHH! Good Jorb, My Gimp!\n"
                          << "Heres Your Game Stats:\n\n"
                          << "Number Of Guesses: "
                          << loopCount << endl
                          << "Score: "
                          << score << endl
                          << "Good Job, Ol' Chap! Bye Bye!\n\n";
                     system("pause");
                     break;
            }
    }
}

int main()
{
        //Generates The comps Random choice
     srand(time(0));
     comp = rand();
     compNumber = comp % 50 + 1;
    
    gameLoop();
    guessing();
    return 0;
}



-- Thanks For Any Help!
Advertisement
Well of course it's possible, you just need some file I/O.
Hehe..Guess my number, bitch ;)
Quote:Original post by Sria
Hehe..Guess my number, bitch ;)


:D I want to have a fun when im making my programs. haha

This topic is closed to new replies.

Advertisement