Not entirely gaming related.

Published July 18, 2005
Advertisement
Well, yesterday was a slightly unreal experience. I went to the Larmer Tree Festival which is about an hours drive from my house, when we got there it was completely and utterly boiling, and guess what...WATER SHORTAGE!!! Thank god my parents had brought a couple of bottles. The first band we saw were called Last Night's Fun, they were absolutely superb, even though folk music isn't exactly my thing =P. The lead singer was a really funny, witty guy aswell.

Anyway, as soon as the hottest part of the day was over I decided to have a look around, I found two other 13 year olds busking for some lunch by doing some pretty uber diabolo tricks, I decided to watch for a bit (I didn't pay anything =D) Then got talking, it turns out his parents have a stall there every year so he had been at the festival for the whole weekend. After a while I decided to show them my secret move; a back somersault (heheh) they soon got me to join in and by the end of the day, I'd made some great friends (along with a 17 year old and an 18 year old (both potheads >_<)) and in the process had made GBP5 from busking! Oh and another thing to add is that all these people thought I was 18...WTF?!?!

One guy we were busking from was a bit out of it though...I did my backflip, front flip and side flip, then he rambled on for the next 15 mins about how I'm 20 times better than ANYONE in the Olympics...it was...interesting. If any of you want a vid of my ubor haxxor skeelz, feel free to ask =)

Anyway, onto gaming related news; while sitting here waiting for the Beta release of Rivaled Fate (it should be any minute now) I decided to revise my code a bit, here's the new code:

//Testing what I learnt in Chapter 1.#include #include using namespace std;    enum armour {LEATHER = 10, CHAINMAIL = 20, PLATEMAIL = 40};    armour myArmour = LEATHER;int main(){    const int MAX_ITEMS = 10;    string inventory[MAX_ITEMS];    int numItems = 0;    inventory[numItems++] = "myArmour";        cout << "Battle Aftermath.\n\n";        const int UNDEAD_EXP = 25;    int undeadKilled = 7;    int undeadPoints = UNDEAD_EXP * undeadKilled;    cout << "Undead Points: " << undeadPoints << ".\n";        cout << "Congratulations, you have slain " << undeadKilled << " undead beasts and gained " << undeadPoints << " Experience points!" << "\n\n";         const int HUMAN_EXP = 10;    int humansKilled = 16;    int humanPoints = HUMAN_EXP * humansKilled;    cout << "Human Points: " << humanPoints << endl;        cout << "Congratulations, you have slain " << humansKilled << " human gladiators and gained " << humanPoints << " Experience points!" << "\n\n";         const int ALLIES_EXP = -10;    int alliesKilled = 4;    int alliesPoints = ALLIES_EXP * alliesKilled;    cout << "Allies Points: " << alliesPoints << endl;        cout << "Although you battled well for your team, " << alliesKilled << " members were brutally massacred, putting a burden of " << alliesPoints << " experience on your team..." << "\n\n";        int totalPoints = undeadPoints + humanPoints + alliesPoints;        if (totalPoints > 20)                  cout << "You have earnt the right to a new set of armour.\n" << endl;        cout << "1 - I'll keep my armour thanks.\n";        cout << "2 - I'll upgrade to Chainmail please! (" << CHAINMAIL << " points)\n";        cout << "3 - I'll upgrade to Platemail please! (" << PLATEMAIL << " points)\n";         int choice;    cout << "Choice: ";    cin >> choice;        switch (choice)    {    case 1:            cout << "You have chosen to keep your current armour.\n";            break;    case 2:            cout << "You have chosen to upgrade to Chainmail!\n";            break;    case 3:            cout << "You have chosen to upgrade to Platemail!\n";            break;    default:            cout << "Please choose a number from 1-3\n";    }   else        cout << "Sorry, you have not earnt enough points to buy a new set of armour.\n";                cin.get();}


I'm getting a parse error for else, and can't see what it is, any help please?

More updates soon, bye!

edit: oh and I realise that I've done the inventory bit wrong but I think I know how to fix it, it's just the else code that I'm stuck on, later on today I'll make it so that it takes away my leather armour and replaces it with whichever the user chooses.

edit 2: added the bit about the crazy guy.
Previous Entry Basic code.
Next Entry YAY!!!
0 likes 3 comments

Comments

ukdm
It looks to me like you are missing some curly brackets around your if-statement. After the if(...) you need to put an opening { bracket followed by a closing } before the else.

Like so...

if (totalPoints > 20)
{
///code
}
else
...
July 18, 2005 05:44 AM
choffstein

    if (totalPoints > 20)          
    {    cout << "You have earnt the right to a new set of armour.\n" << endl;
        cout << "1 - I'll keep my armour thanks.\n";
        cout << "2 - I'll upgrade to Chainmail please! (" << CHAINMAIL << " points)\n";
        cout << "3 - I'll upgrade to Platemail please! (" << PLATEMAIL << " points)\n";
     
        int choice = -1;
        while(choice == -1)
        {
           cout << "Choice: ";
           cin >> choice;
    
           switch (choice)
           {
           case 1:
               cout << "You have chosen to keep your current armour.\n";
               break;
           case 2:
               cout << "You have chosen to upgrade to Chainmail!\n";
               break;
           case 3:
               cout << "You have chosen to upgrade to Platemail!\n";
               break;
           default:
               cout << "Please choose a number from 1-3\n";
               choice = -1;
               break;
         }  
      }
   }
   else
   {
        cout << "Sorry, you have not earnt enough points to buy a new set of armour.\n";
   }



If statement and else statement fixed, and added better code flow with a while statement, so you keep asking until they choose.
July 18, 2005 08:26 AM
Kudu
Cheers both of you =D
Shame it didn't cover that in the book, maybe it's a bit later on. ++ed for helpfulness.
July 18, 2005 10:12 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Wow...

673 views

YAY!!!

615 views

Basic code.

592 views

Basic code.

717 views

w

528 views

A quick hello!

571 views
Advertisement