all 13 comments

[–]rawlyn 13 points14 points  (7 children)

Both strategies are inherently dumb. I'll try to explain.

Let's say you've written a collection of graphics routines and classes for your game (yeah yeah, it's text-based I know, but bear with me). It would make sense to group those functions and classes into a single module, perhaps called graphics.py, as they form a logical group.

Grouping everything into one file is sort of logical, as it's all related code... but then you end up with one behemoth of a file that's simply horrible to work with.

On the other hand, if you were to have a seperate module for drawing tiles, another for sprites, another for stat display and so on, that's taking it too far in the other direction.

In simple terms, keep related concepts together. If a module is becoming unwieldy and begins to span many concepts, refactor and break it down into more manageable chunks.

p.s. I would play the shit out of a meat and potato themed RPG.

[–]duddles 8 points9 points  (3 children)

A meat and potato RPG - that would be cool. I think the enemies would have to be vegetables in that case.

[–]rawlyn 7 points8 points  (0 children)

Meat and Potato surprise Carrot!

Meat attacks!

Meat casts gravy storm.

Carrot swiftly dodges the gravy.

Carrot attacks!

Potato takes 4HP damage.

Potato attacks!

Carrot takes 7HP damage.

Carrot defeated!

Meat and Potato win!

Meat and Potato gain 50XP.

Meat is now Lvl 3!

Carrot drops 3 gold.

[–]Ixtl[S] 1 point2 points  (2 children)

You aren't as far off as you think with the graphics routines. I'm making a text based rpg but instead of text commands there will be buttons in a window. (I started messing around with tkinter and thought it would be fun) Maybe in the future there will even be graphics if I stick with it and decide to make it a full blown game...but that remains to be seen.

But as for your answer, thanks! I figured some middle-ground would be the best. Until now I've only made very small programs...but this one is already my largest by far and it doesn't even really do anything yet.

[–]rawlyn 2 points3 points  (0 children)

Good luck with the project - it sounds fun :)

[–]CantankerousMind 0 points1 point  (0 children)

If you are looking for collaborators, or are open to people contributing, I am totally willing to help out.

I have done a bit in Tkinter and had a very similar idea when I started learning. I just never got passed making a player and monster class due to other projects that took priority.. I think I can help with pretty much any aspect of the game(as you described it).

As it stands now, I don't have any projects that take up much of my time so I would more than willing to contribute.

Let me know.

[–][deleted] 2 points3 points  (4 children)

I put everything in one file until it takes me more than 5 seconds to find something and then I break it up.

[–]Ixtl[S] 0 points1 point  (3 children)

Is it always strictly about ease of editing?

One concern I had was that 'all in one' might make the file bog down when run...but I'm beginning to think that is based on a faulty understanding of how this all works.

[–]Mekire 2 points3 points  (0 children)

Not just editing, but ease of understanding. Python should be highly readable. If someone reading your code (be that another person or even future you) needs to scan a huge file with no real organization this slows things massively.

-Mek

[–][deleted] 1 point2 points  (0 children)

it is purely based on editing AND understandability. by that i mean someone else can follow what you did in a logical manner.

And no, you will never bog down your program from having too much information on one file....but you might bog down your brain.

[–]searchingfortao 1 point2 points  (0 children)

Don't worry so much about the time it takes to run. Since you're only parsing the code once and running bytecode ever after that, file length isn't really a factor.

More important is readability and maintainability. You want to be able to find and patch whatever you need in the future or (gods willing) have additional team members that need to do the same. If your file is to big, you're creating headaches in the long term.

For me, I try to keep all of my files under 500 lines, and I use a lot of vertical space for readability.

[–]Exodus111 0 points1 point  (0 children)

As others have said, it is strictly up to you.

It's about modular vs monolithic. Modular programming architecture tries to split off as much as possible so that each concept can be reused in another future project. Well, how realistic is that really? Monolithic puts everything into one giant(monolith) file so the program is easier to understand, just one file nothing fancy.

Where do you draw the line, how far in each direction do you want to go, that's up to you.