#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    Would I use class inheritance for this, and if so, how?


    I feel like this is an embarrassingly simple question, but all the books I've been reading so far say nothing about it, and web searches aren't helping either. I'm a huge beginner, by the way.

    I'm making a text-based game right now. I have each area or scene in the game divided in to its own class. I would like for the player to be able to name their own character- so in the beginning scene/class, they insert their character name through raw input, and then as they continue through the areas/scenes/classes, the name is remembered by game text.

    Problem is, I have no idea how to go about this. I can have it be remembered for one scene/class, but as soon as another one is moved to, the game doesn't remember anymore. I'm not even sure what I should be reading about to learn about how to do this- class inheritance, or something else? So far all the tutorials, guides and such I find on class inheritance are not covering how to have things inherited that were received via user input.

    Hopefully this was clear enough. I'm probably using some terms wrong since I'm pretty new to this.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Iran
    Posts
    149
    Rep Power
    139
    Your game specification is not clear.

    Besides, as I understand (correct me if I'm wrong), you have to remember successive positions of the user. I don't see any link between this and class inheritance. I would rather use a recursive data structure (a tree for example) or at least a sequence type already available in python for example a list and a counter variable holding the current searched position in the list.

    Take a look here, it might help: Sequence Types str, bytes, bytearray, list, tuple, rang


    Regards,
    Dariyoosh

IMN logo majestic logo threadwatch logo seochat tools logo