Hi
I am programming in C# in Unity I created a game and I published it. So i am quite familiar with writing code. I will be starting a new project soon.
I need help with learning more about code/game design. I will describe below what I struggle sometimes, I am not certain of and I would like to improve on.
I am not sure how to name this subject so I am looking for advice. What course to take what books to read and how this subject is called. I cant really find like a full rulebook about those practice.
What I am not certain and sometimes struggle with is:
What is the best way to organize classes
-what is the best way to split tasks between the classes
-When certain task should have separate class
-Which game object should hold certain class
-Should I control the objects from the class attached to the objects or make external game object with class that will control all objects
-Should input class be attached to the game object that it controls or separate object
-What is the best way to split tasks between classes
-How to pass information from one class to another when needed
As I said I know technically how to implement the functionality of above but how to learn what is the best practice and how to organize it in a proper manner.
I know the answers to some degree but I want to learn best approach.
Please advise best course to take to learn this.
If I search for example “game design” then the course is not really about this kind of things.
I know how to make a game but I want to organize classes in a professional way so it will be easier to handle.
I am looking more for answer about how and where to learn this subject. How to search for the answer.
I am not looking for someone to answer about best Solutions cause I am.not asking about any specific project. I need the course/book/tutorial that will be comprehensive enough that will give general guidance for multiple solutions.
We talking about rather simple games not massive massive ones.
Thanks Wojciech
The topic you’re trying to describe is called software architecture, and the good news is that there are a ton of resources available on that topic. A phrase you can search for and that you’ll hear a lot when talking about software architecture is “Programming Patterns” or “Design Patterns.”
- The first and best resource I use: Design Patterns, by the Gang of Four
- There’s also a blog I refer to that’s specific to how programming patterns can apply to games: Game Programming Patterns. (Pay particular attention to the State pattern. It takes some thinking to apply it to unity’s system of MonoBehaviors, but I just used it to completely revamp my player character, and now it’s 10 times easier to debug & build new behavior into my player whenever).
- You’ll also want to learn how to read UML diagrams, if you don’t already know how. They’re a visualization tool that’s not specific to any one language. I took a college course that taught me this, but there are plenty of youtube tutorials lying around on this topic. It’s really good for planning out solutions ahead of time. It saves time, since you don’t have to worry about the specifics of code. Just general structures.
Some other topics/principles you’ll want to research:
- Object Oriented Design
- Information Hiding
- Single Responsibility (Each class does ONE job and does it WELL). It’s still up to you to decide what consists of one job, but I tend towards smaller, less complex classes in general.
- Cohesion (Good, and answers 4, 5, and 6)
- Coupling (Bad, also answers 4, 5, and 6)
- Composition vs Inheritance (1, 2, 3, and 7)
- Refactoring (A good reference book for this is Refactoring: Improving the Design of Existing Code)
- Finite State Machines (This should be familiar to you if you’re comfortable with the animation controller).
- Dependency Injection (this addresses point 8)
The most important thing to remember, though, is not to overuse patterns, or use them just because they’re cool. That can backfire just as much as rushing in without a plan.
Thank you for information that is exactly what I was looking for.
I have ordered books already:
- Refactoring: Improving the Design of
Existing Code 1st Edition by Martin
Fowler
- Game Programming Patterns 1st
Edition by Robert Nystrom
- Design Patterns: Elements of
Reusable Object-Oriented Software
(Addison-Wesley Professional
Computing Series) 1st Edition,
Kindle Edition by Erich Gamma
(Author)
- Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development (3rd Edition) 3rd Edition
by Craig Larman (Author)
- UML Distilled: A Brief Guide to the
Standard Object Modeling Language
(Addison-Wesley Object Technology
Series) 3rd Edition, Kindle Edition
Best regards
Wojciech