Tag Info

Hot answers tagged

176

There are a multitude of ways to represent and implement entity component systems, but here is an explanation of one way. Keep in mind there is no concrete definition of entity/component/system architectures, so this is just one implementation. I'm going to introduce an analogy for entity/component/system architectures that might help. Let's think of an ...


100

As the quote says, many programmers make the mistake of (trying to) build a system, not a game. Typically that system keeps ballooning out of control until it's so complex that theoretically it can handle anything, but in practicality all you have is a big bundle of code. Or more often, before you even get to a working stage, you are so tangled up in code ...


72

The main game loop handles three major tasks: Get user input Update the game state Draw the game A simple game loop just mushes these three tasks into one while loop. This has some undesired results: Game runs at different speeds on different computers. CPU (can be needlessly) pegged at 100% usage. "Game states"/menus are missing or mixed with game ...


55

Good question! Before I get to the specific questions you asked, I'll say: don't underestimate the power of simplicity. Tenpn is right. Keep in mind that all you're trying to do with these approaches is find an elegant way to defer a function call or decouple the caller from the callee. I can recommend coroutines as a surprisingly intuitive way to ...


45

No it shouldn't. The only thing you'd be using from the inheritance is the x and y components. The methods used in a Vector2 class wouldn't be useful in a Vector3 class, they would likely take different arguments and perform operations on a different number of member variables.


41

I'd recommend Glenn Fiedler's article about robust framerate independence, "Fix Your Timestep!" (Less relevant to the topic at hand, but the other articles in the series are also quite good - as is everything on his site!)


39

When you need a single instance of a class throughout your program, we call that class a service. There are several standard methods of implementing services in programs: Global variables. These are the easiest to implement, but the worst design. If you use too many global variables, you will quickly find yourself writing modules that rely on each other ...


39

Unlike other art forms, vector art requires extremely high precision, making it unsuitable for many art styles. Basic shapes and such are easy using Vector art but it's just a pain to add small details which would be really easy to paint. So its kinda restricted to very simple "symbolic" styles. For everything else painting just works better. What vector ...


36

i want to implement it on my own to learn stuff. That's probably the most important thing. If your goal is to learn, writing your own rendering and game loop engines from scratch is fine, and a perfectly good learning experience. If your goal is to make a finished game quickly and easily, then use an existing framework.


32

This is an expansion of my comment to a full answer, as suggested. Yes, plain and simple. Communication needs to happen and while there are situations where 'Are we there yet?'-type polling is required, having things check to see if they should be doing something else generally wastes time. You could instead have them react to things they are told to do. ...


29

Vector graphics are usually more efficient than raster graphics for storage (ie. the filesize is smaller) but considerably less efficient for performance (ie. how much time it takes the computer to draw the image). In order to display an image the computer must rasterize that image (ie. calculate the pixels in the image). Since raster graphics are by ...


28

I think a kind of robust solution would be to go the object oriented way. Depending on what kind of achievement you want to support, you need a way to query the current state of your game and/or the history of actions/events the game objects (like the player) have made. Let's say you have a base Achievement class such as: class AbstractAchievement { ...


28

I think you're just arguing semantics here. It's called Game State because it behaves like a Finite State Machine, with a finite number of states and transitions between them. The 'Game' in 'Game State System' refers to the overall system, with 'Loading', 'MainMenu' etc being states of the game. These could easily be called 'scenes' or 'screens' or 'levels'. ...


28

First of all, you when build component-based systems, you don't have to take the approach of turning everything into a component. In fact, you generally shouldn't -- it's something of a neophyte mistake. In my experience the best way to tie together rendering and physics systems in a component based architecture is to make those components little more than ...


27

This excellent article covers a lot of the issues: http://www.gamasutra.com/view/feature/2029/developing_your_own_replay_system.php A few things that the article mentions and does well: your game has to be deterministic. it records the initial state of the game systems on the first frame, and only the player input during gameplay. quantize inputs to lower ...


23

Here's my original answer to a similar question on SO from a while back, at least concerning the MVC part of your question: It's rarely used in games. It took me a while to figure out why, but here's my thoughts: MVC exists to make a distinction between two representations. The Model is the abstract representation of your data. It's how the machine views ...


23

What you do depends on the nature of the achievement. Unless your achievements all fit a simple pattern (collect X number of Ys), you're going to have to special-case them to some degree. Using a message-based communication system, you can provide hooks that makes the special-case coding localized. You can have certain actions fire messages to listeners who ...


21

The less experience you have, the more time you waste with up-front design. Making good designs is something that you will learn by doing it and then seeing/evaluating how it turns out. Some decisions have far reaching but obscure implications. After some games you will probably be able to make the initial design pretty solid and it will pay off to invest ...


21

One of the tenants of TDD is that you let TDD in some cases influence your design. You write a test for system, then write the code to make that test pass, keep dependencies as shallow as possible. For me, there are only two things I don't test as part of unit testing: First, I don't test visual elements and how things look. I test that and object will be ...


21

C++ does everything C does. You can trivially mix C and C++ in cases where the advantages of C outweigh those of C++. This is a very intentional design decision of C++. C++ does things that C does not. This includes easy polymorphism, but also easy compile time code generation via templates. This is really handy for things like containers, which are ...


21

TL;DR: Your game objects do not know about each other, nor do they perform checks against other objects. You create a collision detection and collision resolution pattern that checks your game objects and performs the appropriate actions to simulate your game physics. The Good Stuff From previous attempts at writing collision detection and reading this ...


20

I somewhat support using an MVC structure even for a simple mobile game. If nothing else, it helps with an issue that plagues developers who haven't gotten bitten by it enough times: separating the display code from the game logic. I'll also say, though, to keep in mind that MVC, like all design patterns, exists to make your life easier. That means that ...


20

In an average game, there are hundreds or maybe thousands of obects in the scene. Is it completely correct to allocate memory for all objects, includiding gun shots(bullets), dynamically via default new()? That really depends what you mean by "correct." If you take the term quite literally (and ignore any concept of correctness of the implied ...


19

There is no one perfect mapping that gives you a platform specific abstraction, because obviously most of the identifiers that make sense for a 360 controller are wrong for a PlayStation controller (A instead of X, B instead of Circle). And of course a Wii controller is another thing altogether. The most effective way I've found to deal with this is to use ...


19

Event based design mostly involves implementing the Reactor design pattern. Before starting to design components you should give a look to the limitations of such pattern (you may find a plenty information about this). The first and foremost of the problems is that the handlers have to return quickly, as every one that did some serius work on GUI based ...


19

Game Engine Architecture has some information regarding this topic. The basics are that you need to do some analysis to understand what your memory requirements per level/frame/etc. are like, but there are a few patterns the author mentions having seen several times: Stack-based allocators: These allocate a large segment of memory once, and then allocate ...


19

Save the seed which you used to generate the world, and the modifications either as atomic "commands" or the results of those. Then when loading the saved game, you do the following: Procedurally generate the part of the world you're currently visiting. Apply the saved commands, or overwrite the generated elements with the saved ones. Update: And of ...


18

These names vary by region, company and developer. Most of them are made up and are often just synonyms for "thing". Create names that describe the purpose of the code. A frame rate clock is called a frame rate clock. There's no dictionary for these things. You can't have a dictionary if the objects you're describing don't have a firm definition. The ...


18

Put it wherever you can to make it work. Anything else is design paralysis and just going to slow down your progress. When you start seeing patterns emerge, refactor your code. Lots of people will give you advice about the One True Way to do something, but without a breadth of experience to draw from, you'll just be parroting ideas without a true ...



Only top voted, non community-wiki answers of a minimum length are eligible