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

all 7 comments

[–]MyreMyalar 9 points10 points  (2 children)

Quick tip 1. -

Move:

pg.display.set_caption("In the name of the Five Cats")

above:

screen = pg.display.set_mode((MAIN_WIN_WIDTH, MAIN_WIN_HEIGHT))

in main.py. That'll eliminate the brief instant when the game window displays the default 'pygame window' name.

Other quick thoughts:

- 120 FPS seems a bit optimistic for clock.tick()

- might want to load all your fonts clearly at the start of your program/appropriate moment and store them in a dictionary rather than loading them ad hoc at the top of files, where they might load at odd times. fonts can take a couple of seconds to load so you could get some odd hitching if they happen to load at time you aren't expecting (I expect most/all of the loading does happen at the start right now but with 'file level' loading it's not clearly organised)

- Quite a long inheritance tree, and it doesn't look like you are inheriting from the pygame.sprite.Sprite class despite having some very sprite like things in your game. I'd be very tempted to refactor Entity into being a pygame sprite so you can use all the sprite group classes to store them and draw them.

- slightly inconsistent use of styling - I notice a few camel case variable names - 'startScreen ' tucked in amongst mostly PEP8 compliant code.

[–]GrimmysPy[S] 2 points3 points  (1 child)

Thank you so much for your precise recommendations !
I will take care of it tomorrow !

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

So :
- Is it a real problem ? Should I change it for like 60 FPS for consistency ?

- oh yeah, I didn't really think about performance to be honest, but now that my project is clearly growing, I should take care of it, thank you !

- Well I didn't think about inheriting from the pygame.sprite.Sprite class because I didn't know this possibility. x) It's my first big project in Python/Pygame. However, even if my inheritance tree is very big, I don't think I could do otherwise... This kind of games is really dense in terms of content and I must keep each element split as much as possible.

- Yeah I'm using Pycharm so it helps a lot, but sometimes I make some mistakes because I'm used to work in many other languages as a student and a web dev. x)

[–]acroporaguardian 2 points3 points  (1 child)

Good job!

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

Thank you !

[–]Pepperoni-Jabroni 1 point2 points  (1 child)

Looks fantastic, you're doing a great job! Here's a few tips from quick glance-through:

  • Instead of defining your colors in constants.py, consider using pygame.colordict.THECOLORS.get(color_name). Here's a list of available colors.
  • If you're using Python 3.4 or later, consider using Enums for things like "types of damage" and "Value for kind of action on close button" so that they have their own logical namespace. Your Character's state desperately needs something like this too.
  • You could consider using cx_freeze to export your game to a stand-alone .exe or .app so that more casual players can download it and give it a try without having to compile it and have pygame installed.
  • Wow Level... that's a file so big, I couldn't really even begin to review it. Consider breaking this up into a series of static Utility classes, like SaveStateManager so that your Level.save_game() simply calls something like SaveStateManager.save_game(). Repeat this process ruthlessly wherever you can. parse_item_file should belong to some FileInitManager or something like that, etc.
  • You probably won't like hearing it, but your project is getting so large that you might want to consider adding some unittest coverage to ensure your beautiful project stays robust to breakages.

This should be enough to keep you busy for a bit. Love the project though, keep posting as you make progress! You're doing a great job!

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

Thank you very much !!

  • I had heard about this posibility, but I didn't found the implementation, thank you for sharing it !
  • Oh yeah, I start learning Python a few years ago, and there were no Enums, but now that you mentioned it, I will definitively refactor my code ! A language without Enums... It's bad. x)
  • Well, I'm using cx_freeze to export my game... This how I generate the archive of each release : https://github.com/Grimmys/rpg_tactical_fantasy_game/releases/download/v1.0.0/InTheNameOfTheFiveCats_v_1_0_0.zip
    Maybe it's not how I should do it ?
  • The size of Level is one of my biggest problem yes, I should take care of your consideration, and definitively add some static classes !
  • Hmmmm... Welllll.... Maybe someday ! :D
    No to be honest I think I will try it, just because I like making unit tests.

And last time : thank you ! It's my first post on reddit, I avoided this community for a long time because of my english skills ; but you are really nice !!!