250: GameDev: Design Patterns: Entity Component System.

Take Up Code - Un pódcast de Take Up Code: build your own computer games, apps, and robotics with podcasts and live classes

Categorías:

This design pattern will help you make sense of your game design as it gets bigger. You can listen to episodes 77, 86, 87, and 88 for more information and background. This episode will start tying things together. I didn’t originally describe this because it really is a merging of many patterns. But as I started coding this myself, I’ve realized that there’s more to it than just sticking a few design patterns together. Enough that you can benefit from a description. Here’s the big picture. Your game will likely have many characters and objects in it. The characters can be directly controlled by one or more players or be controlled by the game as either direct opponents or just background characters. And the objects can be almost anything that your character interacts with. This could be a weapon, or an apple, or a door or table. All of these characters and objects share certain abilities and behaviors. That’s normally a good sign to use inheritance in your design. But if you go that way, you’ll find that inheritance leads to large and complicated hierarchies of classes that are difficult to change. Listen to the full episode to learn more about how the patterns work together to keep your game design understandable as it gets bigger. Or, you can read the transcript below. Transcript This is something I’ve been working on for the last three months in the game development sessions. You can listen to episodes 86, 87, and 88 for more information and background. This episode will start tying things together. And if you’d like to participate in these game development sessions, you can really learn a lot more than what I can describe here. Listen to episode 248 for a full description of a special offer now through the middle of January. And in that episode, you’ll also hear about a specific example of a template design that I was working on. The best way to participate in the game development sessions is to become a patron. You can get extra podcast episodes, videos, and free game development sessions. Okay, on to the topic for today. This brings together several design patterns. I didn’t originally describe this because it really is a merging of many patterns. But as I started coding this myself, I’ve realized that there’s more to it than just sticking a few design patterns together. Enough that you can benefit from a description. You can also listen to episode 77 about the observer pattern. That forms a big part of this as well. Here’s the big picture. Your game will likely have many characters and objects in it. The characters can be directly controlled by one or more players or be controlled by the game as either direct opponents or just background characters. And the objects can be almost anything that your character interacts with. This could be a weapon, or an apple, or a door or table. All of these characters and objects share certain abilities and behaviors. That’s normally a good sign to use inheritance in your design. But if you go that way, you’ll find that inheritance leads to large and complicated hierarchies of classes that are difficult to change. And I mean they’re difficult to change both at design time and at run time. You might want to change something about how an object looks or behaves and doing so affects other things in the game because they all inherit from the same base classes. This causes problems and increases the work and time needed to write your code. And it also causes problems when you want something in your game to change how it works during the game. Maybe you want the character to be able to move through walls like a ghost for a short while and then go back to being solid. You’ll have a really hard time designing such a game if you’ve relied too much on inheritance. Episode 86 describes the Component design pattern which can be used to attach behavior to characters and game objects by havin

Visit the podcast's native language site