Tag Info

Hot answers tagged

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 ...


17

As long as you keep your system relatively simple, this should work. But when you add things like temporary skill modifiers, you will soon see a lot of duplicate code. You will also run into problems with different weapons using different proficiencies. Because each skill is a different variable, you will have to write different code for each skill-type ...


16

Which Stats? First, with regards to what stats to implement, you need to work backwards from mechanics to derived stats to basic stats. Determine what effects and mechanics you want during play, and determine how you want those mechanics to work with one another. The important notion when looking at relationships between mechanics is identifying the ...


15

I certainly do - both structural and behavioral - my rule of thumb is that I make diagrams when the cost of making the diagram is less than trying to remember what the hell I was thinking a month later - or when I need to clearly explain myself to some other developer Class diagrams when the inheritance hierarchy becomes sufficiently complex Object ...


15

I like to think that everything around us can be represented, one way or another, through a diagram. Even if it is just a linear diagram representing the transition between the states of a particular object throughout time (like a living being, going through a number of states from birth to death). I use diagrams to lay down my thoughts and ideas for the ...


15

You totally don't need to hand-code combinations. You can instead focus on the properties that each item gives you. For instance, Item A sets Projectile=Fireball,Targetting=Homing. Item B sets FireMode=ArcShot,Count=3. The ArcShot logic is responsible for sending out Count number of Projectile items in an arc. These two items can be combined with any ...


14

The Application.Run call drives your Windows message pump, which is ultimately what powers all the events you can hook on the Form class (and others). To create a game loop in this ecosystem, you want listen for when the application's message pump is empty, and while it remains empty, do the typical "process input state, update game logic, render the scene" ...


13

The common terminology is "structure of arrays" (SOA) and "array of structures" (AOS) which come from C and is most often seen in terms of SIMD work. Typically, the AOS approach is faster, if used appropriately, but SOA tends to be easier to work with (and hence optimizes for the more important quality - development time). SOA, especially in Java, means ...


12

One way Unreal Engine 3 handles it: The bullet gets a collision message saying it hit something, with an argument telling it what it hit. It can then call objectHit.takeDamage(self). The target then gets the TakeDamage message, with a pointer to the thing that hit it, and takes the appropriate action. I personally like this approach because it means the ...


10

Thief did this very well in the Dark Engine with Sources and Receptrons. An object could have both of these properties, with different types. For example, a Water arrow would have a Source for WaterStim on contact. An explosion would have an AoE FireStim. When a Water Arrow hits an object, the target object then searches its Receptrons for anything looking ...


10

Mick West's article explains the process of linearising entity component data, in full. It worked for the Tony Hawk series, years ago, on much less impressive hardware than we have today, to greatly improve performance. He basically used global, pre-allocated arrays for each distinct type of entity data (position, score and whatnot) and references each array ...


10

I can't imagine designing a game without using object oriented programming, because my entire understanding of how to design a game-program is based on OOP. Then it will probably be good for you to try writing some programs in non-OO style. Even if you discover that this is not pragmatic for you, you'll probably learn a lot along the way that will help ...


9

Just make them global until you determine that it's a detriment to your system. Read this: http://c2.com/cgi/wiki?DoTheSimplestThingThatCouldPossiblyWork Don't add complexity unless you're getting some benefit out of it.


8

I'd say there are two types of diagrams. Formal diagrams and scribbles. Regarding formal diagrams, I do them when I'm working with other programmers, but I rarely do so when I'm programming alone. However, that doesn't mean I sit and code whatever comes to mind. In my opinion, the most important thing when programming (or actually anything in life) is to ...


8

String-keying / Hashmaps Are fast, as read time is amortized O(1), meaning that read access is usually very fast, but in worst cases (rare, but not unheard of), it can be quite slow. Worst case results from hash collisions. Implementations sometimes have to be built, or found (for instance, in C). Writing / finding a performant string-keyed map ...


7

Diagrams are a great way to communicate, document and aid your design, and design is the most significant part of software development. UML has a lot of features but you are not meant to use them all at the same time, only the ones that are useful. When navigating in a new city, do you actually stop and look at a map, rather than just continue and follow ...


7

Yes, you're thinking too complicated. It sounds like a lot of your problems could be solved with a messaging system and some additional attributes that allow you to specify some filters, and finally not worrying about being so strict with entities/components. Messaging will help you with some aspects like triggering particles, powerups, and so on. For ...


7

Instead of implementing the decision-making of each entity in itself, you could alternatively go for the controller-pattern. You would have central controller classes which are aware of all objects (which matter to them) and control their behavior. A MovementController would handle the movement of all objects which can move (do the route finding, update ...


6

Precise answer usually (or always?) depends on the specific situation and circumstances but I think it's a good idea to try to model the real-world relations between objects. Like in your example - the human is the only entity that actually does something (takes action). So probably this class should call key and door's methods. Key doesn't have to know or ...


6

Collision Filtering A more robust situation that scales into many layers is to use filtering, which is not the same thing as grouping. This works best by giving every object 2 bitmasks. Category Mask And only trigger a collision if the below is true. (filterA.maskBits & filterB.categoryBits) != 0 && (filterA.categoryBits & ...


6

Part of this is a Technical solution, the other part is a Design solution. Peer to peer for this sort of thing has some fun drawbacks, especially as you're left with an interesting question of which client is authoritative, especially with lots of players. You can round robin between clients (this is actually useful for anti-cheating), but as everyone's ...


6

If you are using an OOP language, this sounds like a good place to employ the Decorator Pattern. When you want to modify how an attack happens just decorate it with the appropriate augmentation. Crude c++ Example: class AttackBehaviour { /* other code */ virtual void Attack(double angle); }; class TearAttack: public AttackBehaviour { /* other ...


6

This is a tough question to answer, cause it really depends on the actual game. Usually there are many tricks involved to make a game feel responsive. The classic Mario games on consoles are often considered still being some of the best platformers due to awesome controls and responsiveness. They've got their own issues, but there are many things you can ...


6

Any object-oriented program can be refactored to a procedural program by replacing all classes with structures and converting all member-functions into stand-alone function which take the object which would be this as an argument. So missile.setVelocity(100); becomes setMissileVelocity(missile, 100); or when that function is trivial, you just do ...


5

You are over-complicating things. I would go so far as to say that even using component-based design is just overkill for such a simple game. Do things the way that makes your game quick and easy to develop. Components help with iteration in larger projects with a huge variety of behaviors and game object configurations but their benefit to such a simple ...


5

First important aspect to consider is: Who are you writing the documentation for? Yourself, modders, map editors/campaign designers? And second, but equally most important: What is the purpose of it? What the documentation should contain in any case is: High-level overview Write a short abstract what is your game about. List what have you used, programming ...


5

Your IDs should be a mixture of index and version. This will allow you to reuse IDs efficiently, use the ID to quickly find components, and makes your "option 2" much easier to implement (though option 3 can be made much more palatable with some work). struct entity { uint16 version; /* and other crap that doesn't belong in components */ }; ...


5

Most entity systems don't use Data Oriented Design. Note that entity system doesn't necessarily imply DOD, it just means splitting gameplay functionality into different component classes giving entities certain features and behavior. You can (very easily) create a bloated and horribly slow Object-Oriented version of an entity system. So entity systems are ...


5

There are several potential problems here. First, not all components need the idea of systems as from "entity component systems." Much simpler and more obvious designs are both quite possible and more "real-world" (I've seen major AAA engines using the simpler approaches; I've never in my life seen a real engine using pure ECS). Components can be regular ...


5

A simple flow, based on experimentation and intuition/common sense: This simply means: integrate the acceleration and velocity from the current step to recover the predicted, next step position and velocity perform collision queries and derive any penalty impulses, forces, friction or whatever resolve the collisions in terms of positions (projected ...



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