Jump to content
  • Advertisement
Sign in to follow this  
Lemony Lime

Beginner Question About Game Design

This topic is 2437 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So, this is something that no one ever seems to talk about in either programming, or game design books/tutorials. (That I've seen anyway.)

I've actually started coding my first real game in python, and I'm wondering... when should I start using multiple files, and what parts of the game should go into their own separate files? I'm assuming it shouldn't all be in one 20 thousand line file. (I mean minecraft has a few hundred, though it's obviously a million times more complex than my game.)

Probably a really stupid nooby question, but I'm really not sure. lol

Share this post


Link to post
Share on other sites
Advertisement
This older article might help shed some light on the topic, but in general you split it up however makes sense to your project. Depending on the language you could be forced to split at the class-level (Doesn't java require that each class is its own .java file?). But you might break up code into files that match the general sections of the game's functionality. It used to be that the biggest benefit to split files is that you didn't have to recompile your entire project just because you changed one small aspect of a single function, now it might just as well be about saving you time by letting you first search your project by files, then by lines when you find the right file.

Share this post


Link to post
Share on other sites
I will recommend you to study software design pattern. You can split classes into separate files but still get spaghetti-code. You better learn how to design a good structure so later you can add and expand the project easily

Share this post


Link to post
Share on other sites
Don't worry, it's very much not a stupid question. There actually arent a ton of materials on the topic. I put together a tutorial that covers this subject but its for C++, so I am not sure how much help it would be for you as a Python programmer. To be frank, even as an experienced programmer, I had some issues structuring my code when it came to Python. For structuring Pythons way, you probably want to read this next.

After that, hunt for as much good code as you can find. This is one of the major downsides to python, lots of the code ive seen has been simply awful, basically just a giant .py file.

Share this post


Link to post
Share on other sites
http://artofgamedesign.com/

This book covers an incredible amount of information regarding game design with the authors own personal touch and experience on each matter and this book is regarded as the best on the subject.

Python is a very clean and very good language to learn scripting/programming with, if you have never done any programming before it is fine to learn with. Please check out the pygame framework here http://pygame.org/news.html. Have a look around on youtube for tutorials using python and pygame to make simple games (there are a few).

I generally have a rule where by I put a single class and all of its methods in a single file and then co-join everything as a package. You can of course use nested classes but there are pro's and cons for this.

Hope this helps.

Share this post


Link to post
Share on other sites
Your question is more general than game design. I'd recommend reading Clean Code, a book by Robert Martin which covers several aspects of good program design and effective code layout which most other books ignore. In general, small files with small classes and small methods is ideal for making code easy to test, debug and extend. I recall that he specifically recommends in his java example staying under 500 lines per file and trying to keep them around 200 lines

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!