Tag Info

Hot answers tagged

17

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


17

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


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


12

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


11

They're typically not even handled by the same machine, much less the same codebase. The user profile is handing by a service that deals only with users. The simulation server deals with in-game things. There may even be another session server that ties the two together. The simulation server has an ID that corresponds to each user, so its Player class ...


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


9

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


9

Isn't the code supposed to be analyzed from top to bottom like in regular Python so that the enemyTurn() is called just once and then the game goes back to waiting for user input? The code is executed just like normal code; your assertion here is correct except that your code doesn't have anywhere that "waits for user input." The function ...


8

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


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

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


7

window.localStroage is a more modern alternative to cookies. It allows you to store (semi-)persistent data in the users web browser which will survive a browser restart. The client-sided javascript can access it without having to consult a server, which makes it quite fast to access from the client. But contrary to cookies, localstorage is not directly ...


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


5

Do I create a country class that contains a bunch of towns? Sure. Do the towns contain a lot building class, most contain classes of people? Sure. Do I make a path finding class that the player can access to get around? Sure. Everything you have suggested above seems reasonable. It may not be the best way for you in the long run, but that's ...


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


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

In object-oriented programming, you expose private data with getter-methods. When your player-class wants to know the terrain-type of a tile, it would call level.getTerrain(int x, int y). That public function of class Level would access the private terrain array and returns the value of the terrain tile. When you don't want the player-class to depend on ...


5

If console only, you have far less hardware related issues, since your pool of supported devices is minimal. With a PC, every last component can be made by someone else. So the list of potential compatibility issues is near endless. The newer Windows platforms have tried to standardize drivers a bit, but that doesn't really change the overall idea I'm trying ...


5

I do it as follows: All OOP classes/methods have access to this. In order to utilise this in a non-OO approach, simply pass in whichever instance (see next point) this should be, as the first parameter. Now, as for instances, you can pass structs into your functions as this, but I find the best way to achieve good cache performance for objects which are ...


5

This is still, essentially, a factory, just not one that creates things via runtime keys. It uses compile-time keys (effectively) instead. You have touched on the major downside: you'll need to make this factory accessible everywhere you want to be able to create entities. This, however, is also an upside because it means you can control what interfaces are ...


5

If it were me I would give each NPC agency of their own - if each one has a simple goal ( get as far as possible from Zombies/get as close as possible to humans ) that they act on, you can get quite interesting behaviours from relatively simple inputs without too much processing. The downside of this is that if you have a lot of them around you are going ...


5

First, Fix Your Timestep. The component update should always have a fixed time interval. This is critical for stable physics and can avoid bugs in other systems as well. You may have cases where the time interval becomes huge, too. This can happen if you set a breakpoint while debugging. You'll want to cap the update time used for the time accumulator ...


5

AI being costly, performance is often the driving factor in architecture. To ease your concerns around data access models, let's consider a few different AI examples both in- and outside of the games industry, working from that which is furthest from human navigation to that which is most familiar to us. (Each example assumes a single, global logic ...


5

What you describe is a classic "pull" model of querying the world. Most of the time, this works pretty well, especially for games with basic AI (which is most). However, there are a couple of points you should consider that might be downsides: You probably want to double buffer. See game programming patterns on the subject. By always requesting the data ...


5

If you're already putting in solid efforts to abstract engine code from game code, AND you want to keep your various game projects up-to-date with the latest version of the engine, then and only then would I suggest keeping it in a separate repository, since that would make it worth the effort. Otherwise, if you're only developing a single game, don't worry ...


4

I'm assuming you know how basic matrix math works, so I'm not going to cover that in my answer. What you eventually want to do is transform the vertices of the object you want to render from the virtual 3D world to the "real" 2D world (your monitor screen). You do that by multiplying the vertices of the object with a camera matrix (some people may use other ...


4

A common approach is to write separate renderers or renderers with "feature gates." That is, you can make separate files for each API (GraphicsGL2.cpp, GraphicsGL4.cpp, etc.). You can then make some kind of IRenderer interface each implements or you can simply have one header and conditionally compile the renderer .cpp files for each platform (compile-time ...


4

Why not use associated arrays?, this gives the benefit of being easily extended (using PHP for example) $Stats["Strength"] = "8"; $Stats["Dexterity"] = "8"; for things such as weapons, you would probably want to create some base classes Weapon -> MeleeWeapon, RangedWeapon and then create your weapons from there. The end result I would aim for is a ...


4

This is one of those "It depends..." answers, be forewarned :) The complexity of collision detection in 3D depends on the complexity of the bounding volume for solids. By bounding volumes, I mean what shape you are wanting to consider for the collision calculations. You might be drawing a really complicated spikey ball on the screen, but consider that ...


4

Because operations dealing with objects and their locations, such as collision detection and filtering nearby objects, are so heavily used in games, it is common practice to use one or more spatial data structures to describe your world. Some examples of these structures are grids, octrees, or the classic scene graph - a tree storing relative ...



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