I'm writing a game using Python and PyGame. (This is perscribed in the assignment, so it's no use suggesting another game dev. library that has built-in level parsing)
I'm at the stage now where the game physics etc. are complete, but I am yet to work out a method for saving and loading levels into the game. Here's what I've thought about it so far:
All I'm looking for are suggestions of the best method for achieving this.
TL;DR - Best way to parse game levels from file into Python / PyGame.
If you don't need to edit by hand, or read the levels in any other program, just use pickle.
Store your level data in a single Python object, and it's (nearly) a one-liner in your code to read and write.
Pickle is made for this sort of thing. You don't need any delimiter to differentiate the items in a list; just pickle the whole list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With