Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Collections (2016, retired 2019) Dungeon Game Win or Lose

Extending the Dungeon Crawler game

I've just finished my extension of the dungeon crawler game and would love any feedback. There's a snapshot here: https://w.trhou.se/qb9plaqncz (click on dungeon.py on the left) Either fork and run in your workspace, or copy/paste into python 3 to try.

Features I added:

  • Main menu
  • Score
  • Debug Mode
  • Chase Mode
  • Player instructions
  • Display rooms previously visited
  • Monster AI

I know I could still refactor especially the game_loop function, and I'd like to add multiple monsters/persistant score at some point... also have an idea for locked doors and item chests...plus a custom game mode but I think I'll leave it here, maybe re-write it in OOP at the end of the next course!

Thank you in advance to anyone who takes the time :)

Jon

P.S. tagging Kenneth Love (Sorry in advance if that's inconvenient Kenneth)

Try to tag Kenneth, we'll get to hear some great things from him.

Thanks Krishna Pratap Chouhan,

Do you know how I could tag someone? Never mind figured it out lol; it's kind of like everywhere else, use the @ lol!

1 Answer

Greg Kaleka
Greg Kaleka
39,021 Points

Very cool Jon!

Persistent scoring is actually pretty easy. Have you played around with the Python function open()?

Here's a workspace with two projects that use the open() function to access an outside text file.

  • hangman.py uses an external word list, so rather than hardcoding in a few words, I've got a list of 100+ words that get pulled in.
  • todo_list.py uses an external text file as a persistence layer. The user can save their list, and the list is written to todos.txt. When the program starts, it automatically loads items from that same file.

Check it out and see if you can figure out saving scores! Persistence is really important, so it's good to get your feet wet early on :blush:

Cheers :beers:

-Greg

P.S. I'm also pinging Kenneth Love because he should definitely see your game! Also he said to in the video :smile: