Quick and Efficient?

This is a discussion on Quick and Efficient? within the Game Programming forums, part of the General Programming Boards category; What would be a quick and efficient way to take a monster class array and store all the monsters stats ...

  1. #1
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65

    Quick and Efficient?

    What would be a quick and efficient way to take a monster class array and store all the monsters stats and crud like that. I don't want like 2 billion lines of code.

    here's what my monster class is:
    Code:
    class monster
    {
        private:
            int hp; //hp
            int mhp; //max hp
            int mp; //mp
            int mmp; //max mp
            int str; //effects damage given
            int def; //effects damage taken
            int mind; //effects skills
            void (*skilla)(class player target); //pointer to skill function a
            void (*skillb)(class player target); //pointer to skill function b
            void (*skillc)(class player target); //pointer to skill function c
            int expg; //exp given when defeated
        public:
            monster::monster(/*arguments*/)
            monster::~monster(/*arguments*/)
            //possibly more functions
    };
    Any help is appreciated. Thankie Thankie
    Last edited by MMD_Lynx; 08-11-2004 at 07:48 AM.
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,499
    Overload the << operator so you can do

    out << monster;

    Which internally is just say
    out << hp << endl;
    out << mhp << endl;
    etc etc
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65
    i think that's a little above me. i have no idea what u mean. i know what overloading operators is...but i don't know how to. and how would i specify the hp and other stats? these are probably noobish questions...im sry
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Efficient Sorting Algorithm
    By GCNDoug in forum C++ Programming
    Replies: 10
    Last Post: 11-13-2008, 08:06 AM
  2. Quick Ques on String Manipulation
    By ckuttruff in forum C Programming
    Replies: 8
    Last Post: 06-22-2008, 09:32 PM
  3. Just a quick hello!
    By KarrieWojo in forum C Programming
    Replies: 3
    Last Post: 12-01-2007, 10:00 PM
  4. will this methid be efficient
    By ssharish2005 in forum C Programming
    Replies: 1
    Last Post: 01-15-2006, 11:33 AM
  5. Shell Sort vs Heap Sort vs Quick Sort
    By mackol in forum C Programming
    Replies: 6
    Last Post: 11-22-2002, 07:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21