Tag Info

Hot answers tagged

6

It is fine to have lots of instances. An instance of a class without virtual methods is just like a POD C struct in terms of memory consumption which is similar to primitive data types. It is no problem. Your concern when instantiating many instances of a class are resource related I would think. CPU - should not be affected because you will be ...


4

Constructors and destructors in C++ are about the lifetime of the object. Your problem is that you are mixing up the lifetime with the desired behavior of the object. The solution is to decouple them. Give the appropriate entities an "OnDestroy" function, which is called by your game logic when the entity should be (according to the rules of the game) ...


3

I don't think that you should go with static class members (you didn't mention language but I assume some kind of OOP) because that just hides "singleton" in a different place. Switch things around so your Game holds a bunch (map, set, list, array, whatever) of these across-room global puzzles. Make it so your rooms can ask the game about a puzzle it's ...


2

I think a key phrase is separation of concerns. If your code doesn't include the text than the code get's less complex. The programmer writing the code doesn't have to think about the specific text and can focus on the code. He doesn't have to think about localization. The person doing the localization doesn't have to worry about the code.


2

That said, there is no golden rule for that kind of thing, but it will mainly affect your architecture. I would suggest you to take a look at the component pattern (which is used by some game engines such as Unity). This pattern will allow you to to "attach" component on game entity. In your case you will have, for example, a SnakeController component in ...


1

Getting null reference exception is normal since they were created in the previous scene and destroyed in the current one. To move them to the next scene, you need to call DontDestroyOnLoad. Why don't you create your assets after the scene is loaded? GameManager should be responsible for creating player and enemy objects and keep track of the game state. In ...


1

You need to remember that C++ is a multi-paradigmatic (OOP, functional, procedural, ..) language and you should use the programming paradigm that best solves your current issue. OOP doesn't lend itself well to this problem. In OOP you think about single objects in isolation (concept of "a tile"). But most of your algorithms will operate on a whole ...


1

I would advise against using inheritance to manage different tiles. Imagine how annoying it would be having to define a new class every time you add seemingly different types of tiles. That would result in a lot of implementations for simple things like a grass or a dirt tile. It is much simpler and more maintainable to make tiles configurable. Define a Tile ...


1

For engines written by you in native code Separate your render logic out. Every cycle, run all your game / simulation logic in one phase, and once that's all complete, run all rendering logic -- this includes animation. Since rendering and animation are separate, run game logic timers that use the same duration as the animations, but only have game logic ...


1

I guess licensing can also be a reason not to include content in the code. For example, your code might be FLOSS, but you don’t want to license your content at all (maybe you want to publish your game code so that others can use it for creating similar games with different content) your code might be FLOSS, but you want to use a Creative Commons license ...



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