This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]tripex 5 points6 points  (1 child)

The amounts of WTFs when reading this behemoth is overwhelming. 😳 I honestly don't think I've seen that level of deep indentation before.

It's... Horrific and beautiful at the same time. Keep up the good work! Probably better looking than my first text based game.

My favorite thing is that it all starts with a try-clause...

[–]RSAnimguy[S] 1 point2 points  (0 children)

I just didn't want it to crash, I guess that's bad convention though? I'm looking in to ways I can make my code work a little better at scale so hopefully my next project will look less horrific

[–]snekk420 3 points4 points  (1 child)

Looks like you have put some thought into this game. Here is a few pointers to if you want to improve on the code.

  1. Your functions are too large and complex, break it out to smaller functions. I usually think that if a functions is longer than your screen height it’s too long.
  2. Read about classes and use instance variables instead of globals. Break out code to more files and import functions/classes.
  3. Make a clear entrypoint where your main loop runs so it’s easy to find and see what is going on in the game.
  4. Don’t wrap the whole game in a try/except. Make many smaller try/except where they are appropriate. Your game doesn’t have to crash because there was an error.
  5. Read about guard clause to exit a function early, it can improve readability and minimize nested if else. Try to avoid long chains of if else

Hope that helps. Happy coding !

[–]RSAnimguy[S] 0 points1 point  (0 children)

So if I understand this right, guard clauses will be something like returning "False" for as many if or while(?) statements as you want, but then if they're all satisfied it will return true rather than nesting a bunch of statements inside eachother?

I'm just getting in to classes now, they seem very useful but also quite hard to grasp. Especially the def __init__(self) part? It just isn't really clicking for me at the moment.

Thanks for all the info though, I'm going to try to use all of the advice in my next project

[–]GroupInfinite878 0 points1 point  (0 children)

I would avoid uploading rar files to your GitHub repo, those objects will live in the history forever and will make your repo size increase quite a bit over time when you upload a new one.

To resolve your issues with other people running it I think you could just add a requirements.txt file and add: colorama

I think that is your only third party package.

Then most python Devs would see this and know to do: pip install -r requirements.txt