Click here to Skip to main content
15,886,518 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: To bool or not to bool in C/C++ ? Pin
k505421-Feb-20 9:31
mvek505421-Feb-20 9:31 
AnswerRe: To bool or not to bool in C/C++ ? Pin
leon de boer21-Feb-20 11:55
leon de boer21-Feb-20 11:55 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Vaclav_22-Feb-20 5:34
Vaclav_22-Feb-20 5:34 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Richard MacCutchan22-Feb-20 6:47
mveRichard MacCutchan22-Feb-20 6:47 
GeneralRe: To bool or not to bool in C/C++ ? Pin
leon de boer23-Feb-20 5:29
leon de boer23-Feb-20 5:29 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Richard MacCutchan23-Feb-20 6:08
mveRichard MacCutchan23-Feb-20 6:08 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Victor Nijegorodov23-Feb-20 20:43
Victor Nijegorodov23-Feb-20 20:43 
GeneralText based mining game using if and while Pin
Chleba22519-Feb-20 10:41
Chleba22519-Feb-20 10:41 
<blockquote class="quote"><div class="op">Quote:</div>Hello guys, I want to share with you my mini "project" which I managed to do so I can understand c++ better and decided to make mining game with if and while loops. I am in programming for awhile so this is reason why it is not that good.

There are things I would do different (I'm about to do it later). I want to hear your suggestions, opinions etc.. So let me know.

Code:

<pre lang="c++"><pre>

<h1>include <iostream></h1>

<h1>include <windows.h></h1>

using namespace std;

int main(){
    bool start = true;
    int startWay;
    bool marketMine = true;
    int marketWay;
    bool trymarket = true;
    static int copperGot = 2;
    int copperNow = 0;
    int balance = 0;
    int shopWay;
    int item;
    bool market = true;
    string errorInput = "Error, Again: ";
    bool gearBuy = true;
    int pickaxe;

    while(start != false){
        cout << "1. Start\n2. Credits\n>";
        cin >> startWay;
        if(startWay == 1){
            cout << "You awake in old house, you dont have any money but your job is to mine.\nYou can make some money and buy gear and upgrades.\n";
            Sleep(2000);
            cout << "1. Mine\n2. Market\n>";
            cin >> marketWay;
            while(marketMine != false){
            if(marketWay == 1){
                cout << endl;
                cout << "You are going mine..";
                Sleep(800);
                cout << "\nMining...." << endl;
                Sleep(1000);
                copperNow += copperGot;
                cout << "You have got > " << copperGot << " copper and your copper is > " << copperNow << ". \n" << endl;
                cout << "1. Mine\n2. Market\n>";
                cin >> marketWay;
}           else if(marketWay == 2){
                Sleep(1000);
                system("CLS");
                cout << "Welcome on market. Here you can sell ores you have mined and buy better items\nfor more ores or money.\n\n";
                Sleep(2000);
                while(market != false){
                cout << "1. Sell all copper.\n2. Balance\n3. Gear\n4. Pickaxe\n5. Mine\n>";
                cin >> shopWay;
                if(shopWay == 1){
                    Sleep(1000);
                    cout << "You have sold " << copperNow << " copper. You have gained " << copperNow * 2 << "$\n\n";
                    balance = copperNow * 2;
                    copperNow -= copperNow;
                    Sleep(2250);
                    system("CLS");
                }else if(shopWay == 2){
                    cout << "Your balance is: " << balance << "$\n";
                    Sleep(3000);
                    system("CLS");
                }else if(shopWay == 3){
                    Sleep(1000);
                    system("CLS");
                    cout << "Welcome, what do you want.\n\n1. Helm 250$\n2. Chestplate 500$\n3. Legs 400$\n4. Boots 200$\n5. Go back\n>";
                    cin >> item;
                    if(item == 1){
                        if(balance < 250){
                            cout << "Not enough balance. \n";
                            Sleep(2000);
                            system("CLS");
                        }else if(balance >= 250){
                            balance -= 250;
                            cout << "Here's your helm! you now get +1 ore. Your balance is > " << balance << "$ \n";
                            copperGot += 1;
                            Sleep(1500);
                            system("CLS");
                        }
                    }else if(item == 2){
                        if(balance < 500){
                            cout << "Not enough balance. \n";
                            Sleep(2000);
                            system("CLS");
                        }
                        else if(balance >= 500){
                            balance -= 500;
                            cout << "Here's your chestplate, now you get +1 ore. Your balance is > " << balance << "$ \n";
                            copperGot += 1;
                            Sleep(1500);
                            system("CLS");
                        }
                    }else if(item == 3){
                        if(balance < 400){
                            cout << "Not enough balance. \n";
                            Sleep(2000);
                            system("ClS");
                        }else if(balance >= 400){
                            balance -= 400;
                            cout << "Here are your legs, now you get +1 ore. Your balance is > " << balance << "$ \n";
                            copperGot += 1;
                            Sleep(1500);
                            system("CLS");
                        }
                    }else if(item == 4){
                        if(balance < 200){
                            cout << "Not enough balance. \n";
                            Sleep(2000);
                            system("CLS");
                        }else if(balance >= 200){
                            balance -= 200;
                            cout << "Here are your boots, you get now +0.5$ per ore. Your balance is > " << balance << "$ \n";
                            copperGot += 1;
                            Sleep(1500);
                            system("CLS");
                        }
                    }else if(item == 5){
                            cout << "Sending back.";
                            Sleep(1000);
                            system("CLS");
                }else if(item != 1 || 2 || 3 || 4 || 5){
                            cout << errorInput;
                            cin >> item;
                }

        }else if(shopWay == 4){
            Sleep(1500);
            system("CLS");
            cout << "Welcome, here, you can buy pickaxes, but these ones are much more cheaper than gear!\n\n";
            cout << "1. Copper pickaxe 900$\n2. Silver pickaxe 1500$\n3. Gold pickaxe 2,250$\n4. Emerald pickaxe 3,200$\n5. Diamond pickaxe 5,000$\n>";
            cin >> pickaxe;
            if(pickaxe == 1){
                if(balance < 900){
                    cout << "You don't have enough money!\n";
                    Sleep(2000);
                    system("CLS");
                }else if(balance >= 900){
                    balance -= 900;
                    copperGot += 2;
                    cout << "Here's your pickaxe, now you get +2 ores! Your current balancse is > " << balance << "$ \n";
                    Sleep(2000);
                    system("CLS");
                }
            }else if(pickaxe == 2){
                if(balance < 1500){
                    cout << "You don't have enough money!\n";
                    Sleep(2000);
                    system("CLS");
                }else if(balance >= 1500){
                    balance -= 1500;
                    cout << "Here is your pickaxe, now you get +2 ores! Your current balance is > " << balance << "$ \n";
                    copperGot += 2;
                    Sleep(2000);
                    system("CLS");
                }
            }else if(pickaxe == 3){
                if(balance < 2250){
                    cout << "You don't have enough money!\n";
                    Sleep(2000);
                    system("CLS");
                }else if(balance >= 2250){
                    balance -= 2250;
                    cout << "Here's your pickaxe, now you get +2 ores! Your current balance is > " << balance << "$ \n";
                    copperGot += 2;
                    Sleep(2000);
                    system("CLS");
                }
            }else if(pickaxe == 4){
                if(balance < 3200){
                    cout << "You don't have enough money!\n";
                    Sleep(2000);
                    system("CLS");
                }else if(balance >= 3200){
                    balance -= 3200;
                    cout << "Here's your pickaxe, now you get +2 ores! Your current balance is > " << balance << "$ \n";
                    copperGot += 2;
                    Sleep(2000);
                    system("CLS");
                }
            }else if(pickaxe == 5){
                if(balance < 5000){
                    cout << "You don't have enough money!\n";
                    Sleep(2000);
                    system("CLS");
                }else if(balance >= 5000){
                    balance -= 5000;
                    cout << "Here's your pickaxe, now you get +2 ores! Your current balance is > " << balance << "$ \n";
                    copperGot += 2;
                    Sleep(2000);
                    system("CLS");
                }
            }
        }else if(shopWay == 5){
                cout << endl;
                cout << "You are going mine..";
                Sleep(800);
                cout << "\nMining...." << endl;
                Sleep(1000);
                copperNow += copperGot;
                cout << "You have got > " << copperGot << " copper and your copper is > " << copperNow << ". \n" << endl;
                Sleep(2000);
                system("CLS");
        }else if(shopWay == 123456789){ //hidden help for money
            balance += 60000;
            system("CLS");
        }

        else if(startWay == 2){
            cout << "All rights goes to: SM. (Inicials).\n";
        }
        else if(startWay != 1 || 2){
            cout << "\nError, try again.\n\n";
        }
     } //while loop
    }else if(marketWay != 1 || 2){
        cout << "Error \n>";
        cin >> marketWay;
    }
    } // while loop
}
}
}

GeneralRe: Text based mining game using if and while Pin
Stefan_Lang19-Feb-20 21:42
Stefan_Lang19-Feb-20 21:42 
GeneralRe: Text based mining game using if and while Pin
Vaclav_20-Feb-20 17:04
Vaclav_20-Feb-20 17:04 
GeneralRe: Text based mining game using if and while Pin
Chleba22521-Feb-20 20:32
Chleba22521-Feb-20 20:32 
SuggestionRe: Text based mining game using if and while Pin
David Crow24-Feb-20 3:44
David Crow24-Feb-20 3:44 
QuestionCannot open file 'hid.lib' in microsip Pin
Jafar_Ulla19-Feb-20 2:14
professionalJafar_Ulla19-Feb-20 2:14 
AnswerRe: Cannot open file 'hid.lib' in microsip Pin
CPallini19-Feb-20 2:51
mveCPallini19-Feb-20 2:51 
QuestionUse of string class in c++ Pin
Awantika Singh14-Feb-20 21:26
Awantika Singh14-Feb-20 21:26 
AnswerRe: Use of string class in c++ Pin
Victor Nijegorodov14-Feb-20 21:35
Victor Nijegorodov14-Feb-20 21:35 
AnswerRe: Use of string class in c++ Pin
Stephane Capo14-Feb-20 21:38
professionalStephane Capo14-Feb-20 21:38 
GeneralRe: Use of string class in c++ Pin
Awantika Singh15-Feb-20 4:27
Awantika Singh15-Feb-20 4:27 
GeneralRe: Use of string class in c++ Pin
Richard MacCutchan15-Feb-20 5:06
mveRichard MacCutchan15-Feb-20 5:06 
GeneralRe: Use of string class in c++ Pin
Stephane Capo15-Feb-20 21:52
professionalStephane Capo15-Feb-20 21:52 
GeneralRe: Use of string class in c++ Pin
k505416-Feb-20 3:30
mvek505416-Feb-20 3:30 
GeneralRe: Use of string class in c++ Pin
Richard MacCutchan16-Feb-20 4:58
mveRichard MacCutchan16-Feb-20 4:58 
GeneralRe: Use of string class in c++ Pin
CPallini16-Feb-20 7:28
mveCPallini16-Feb-20 7:28 
GeneralRe: Use of string class in c++ Pin
Stefan_Lang16-Feb-20 22:43
Stefan_Lang16-Feb-20 22:43 
GeneralRe: Use of string class in c++ Pin
CPallini16-Feb-20 23:02
mveCPallini16-Feb-20 23:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.