Thread: Best orginization of classes in an RPG?

  1. #1
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877

    Best orginization of classes in an RPG?

    Over the past 2-3 weeks or so I've been learning SDL, and have gotten a pretty good framework for image loading, and manipulating based on various input.

    Originally I was only wanting to write GUI's, but I've had so much fun creating and animating little sprites (my main sprite class even has a "spell" class embedded so it can shoot off fireballs :P) that I began to put more thought into making a game.

    Anyway, to cut it short I've been brainstorming what a good class hierarchy chart for an RPG type game should look like. I did find some good basic examples online, still I thought I would ask here and see if anyone knew of any good examples of a UML type chart for an RPG?

    I'm specifically interested in if most people use a root abstract type base class for game objects, and what should be done with composition, and what with inheritance.

    Thanks for any information,
    Alpo.

    Edit: Also, if anyone has references for good books that discuss this sort of thing, please let me know.
    Last edited by Alpo; 06-17-2014 at 11:10 PM.

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    If you just want existing references, a simple search yielded dozens of examples.

    If you want opinion on your designs, you'll have to post what you have for now.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  3. #3
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Oh man, this topic is so much lamer than I thought it was going to be. I was going to suggest making sure there's always a Dark Knight and like a Dragoon and stuff XD

  4. #4
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877
    There is a dragon. It doesn't even look to much like a pokemon if you squint just right. :P.

  5. #5
    Registered User
    Join Date
    Jul 2014
    Posts
    2
    Several years ago I worked at games & software development company and there we used a root abstract type base class for game objects. At that time it was the best class hierarchy chart for an RPG type game.

  6. #6
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    @Poline - Spamming your site again?

    Announcements - Game Programming
    See #7, if you didn't get the clue the first time.

  7. #7
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877
    Quote Originally Posted by Poline View Post
    Several years ago I worked at games & software development company and there we used a root abstract type base class for game objects. At that time it was the best class hierarchy chart for an RPG type game.
    This is basically what I'm doing, at least for most renderable things (a few exceptions like dialogue boxes, and fonts).

    I ran into a problem a while back when I realized I couldn't use the virtual mechanism to load all the derivative-unique variables with the same function (like for instance a an enemy mage needs different loading variables than an npc ect).

    I got around it by creating a class called LoadingValues. That way I can create a LoadingValue in the XML parser with all the values from the file, and just pass that to the array of base Objects.

    That along with an enum bitmask to identify object types has been working pretty well.

  8. #8
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by Alpo View Post
    Over the past 2-3 weeks or so I've been learning SDL, and have gotten a pretty good framework for image loading, and manipulating based on various input.

    Originally I was only wanting to write GUI's, but I've had so much fun creating and animating little sprites (my main sprite class even has a "spell" class embedded so it can shoot off fireballs :P) that I began to put more thought into making a game.

    Anyway, to cut it short I've been brainstorming what a good class hierarchy chart for an RPG type game should look like. I did find some good basic examples online, still I thought I would ask here and see if anyone knew of any good examples of a UML type chart for an RPG?

    I'm specifically interested in if most people use a root abstract type base class for game objects, and what should be done with composition, and what with inheritance.

    Thanks for any information,
    Alpo.

    Edit: Also, if anyone has references for good books that discuss this sort of thing, please let me know.
    I would highly recommend against any sort of formal hierarchy. Build your components "from the bottom up" and just allow everything to come together naturally. And be mindful of just how much exposure and interconnection each component may or may not need along the way - otherwise you might be facing one of those messy refactoring projects!
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Array of classes with classes inside
    By questionmark in forum C++ Programming
    Replies: 3
    Last Post: 10-04-2013, 03:39 PM
  2. Conversions between base classes and derived classes
    By tharnier in forum C++ Programming
    Replies: 14
    Last Post: 03-18-2011, 10:50 AM
  3. Classes access other classes local variables
    By parad0x13 in forum C++ Programming
    Replies: 6
    Last Post: 01-14-2010, 04:36 AM
  4. Classes with Other Classes as Member Data
    By njd in forum C++ Programming
    Replies: 2
    Last Post: 09-27-2005, 09:30 AM
  5. Help accessing classes and derived classes
    By hobbes67 in forum C++ Programming
    Replies: 8
    Last Post: 07-14-2005, 02:46 PM