Skip navigation

Here you’ll find the ongoing development of a ‘choose your own adventure’ game.  Enjoy!

These games were written in Python 2.7 and are purely designed to be run in the terminal/command window only.

Snowhold (Fantasy, v1.0) – link to download

Snowhold (Fantasy, v2.0) – link to download

Snowhold (Fantasy, v2.2.1) – link to download

Advertisements

12 Comments

  1. After several attempts to get it going I gave up. First I had to rename fantasy_text.py to fantasy_text2.py. Then, after entering 1 twice, I got:
    File “C:\Python33\game-core-2.py”, line 312, in start
    event1(module)
    File “C:\Python33\game-core-2.py”, line 11, in event1
    print(textwrap.fill((textwrap.dedent(module.event1_description).strip()), width=60))
    AttributeError: ‘module’ object has no attribute ‘event1_description’

    If you successfully ran this you must have run different code than what you posted.

    Reading your code I see a few more problems. One being some calls to event1() – no argument, but 1 is expected!

    • Wow, not sure how I got the files confused…..ugh. Thanks. I did a couple of quick edits and made sure the right variables were pointing to the right places now. So it should work fine. Seems I uploaded a partial edit for the next version I was working on.

  2. The best thing you can do is shift directions from brute-force coding of a game (which gets more and more difficult and unmanageable, to a separation of data from logic. Here is where classes are so helpful.

    • What I am doing is exactly that, separating the content from the context. The first version of this has all the flavour text in the same file and the logic. I have yet to find a good example of Classes to understand how they work. So far every example I have seen in any of the courses have either a:/ not been explained properly so they were frustrating(Coursera) or b/ looks just like functions moved to another location in the code(Learn Python The Hard Way).

      I would prefer to use the idea of having a ‘blueprint’ for a section and simply feeding it flavour text based on the genre chosen at the beginning of the game. With each successive version of the game, I am learning to distance content and context, while also learning to debug and properly track things, plus learn some new concepts along the way (i.e. the textwrap was an awesome find).

      So, if you know of a GOOD resource, and by that I mean one that walks you through examples and not just something that says RTFM, Classes will continue to elude me.

      I appreciate your time and effort. If you decide to take another swing at the code, I’d be greatly honoured.

  3. Got the new code. Much better. I will construct an example of how to use classes soon.

  4. Wait patiently while I develop an OOP version of your game.

    Meanwhile learn to use functions to avoid duplicate code. Example:
    def printText(text):
    print(textwrap.fill((textwrap.dedent(text).strip()), width=60))
    and call it thus:
    printText(module.snowhold_description)
    similarly everywhere else you use textwrap.

    Study UML (http://www.tutorialspoint.com/uml/uml_tutorial.pdf). Before you write code you develop a model.

    • Thanks Bob! I am learning all the time! Step by step I am learning how to abstract the code to make it easier. Will immediately make that part of v3 update 🙂

      And yes, no rush to develop the OOP. You are doing me a HUGE favour! I appreciate it immensely!

    • I took at look at that UML….that’s way above my level of learning. That stuff is going to have to wait before I can get what it means.

  5. I have uploaded Introduction To Classes Chapter 1
    https://www.dropbox.com/s/i6uuwrd6vuovbb6/intro_to_classes_1.py.
    Please take a look and let me know how it helps and where I need to explain differently.

    • Hi Bob. Wow, totally forgot about this reply you did. Will be looking into it in the coming weeks as time allows. Thanks for your efforts!!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: