Thread: ISO someone daring to look at some n00b code!

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    13

    Smile ISO someone daring to look at some n00b code!

    I'm beyond n00bdom, but I cannot get the hang of C or C++, so whatever lays between a complete n00b and QBasic

    Anyway! Here's my code. I am trying to come up with a way to produce random items (that would relate to a ye olde RPG).

    The potential problem that I think I'm running into is an insane amount of variables. So, if anyone would be interested in taking a peek, have at it!

    Be kind! *cringes*
    "Whether you think that you can, or that you can't, you are usually right."

  2. #2
    It's kinda odd that you can craft with negative numbers of steel

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    13
    Hmmmm.

    That IS odd. LOL
    "Whether you think that you can, or that you can't, you are usually right."

  4. #4
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    With any kind of genre or game that requires a large ammount of items - tipically rpgs - you need to come up with a flexible variable format (struct) that can hold all pertinant information. Then you just have an array of of items of that struct type.

    IE:
    Code:
    typedef enum ITEM_TYPE { IT_WEAPON, IT_POTION, IT_ARMOR, IT_WHATEVER };
    
    struct ITEM {
        int minDmg; // damage minimum
        int maxDmg;// damage maximum
        int costbase;// cost to purchase and sell to be used in formula
        int craftxp; // xp you gain from crafting object
        char [25] name; // readable name of the object
        int id; // numerical value of item for quick comparisons
        ITEM_TYPE type; // enumerated type of item
    }
    
    
    ITEM gameItems[230]; 
    // might be a  good idea to have a function that can parse a file - with a specific format for item information to fill this array. That way you can modify all your game items in a text file with out recompiling.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  5. #5
    Registered User
    Join Date
    Jul 2003
    Posts
    13
    Thank you goten, I will mull over that a bit.
    "Whether you think that you can, or that you can't, you are usually right."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Proposal: Code colouring
    By Perspective in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 05-14-2007, 07:23 AM
  2. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM