Hot answers tagged

7

At the moment I'm using std::shared_ptr to support multiple ownership of GameObjects so that they are held by both the scene and any other GameObjects within the game Don't do that. shared_ptr is often the wrong tool for the job, and that certainly applies here. Remember that smart pointers are for managing ownership; shared_ptr is about sharing ...


7

Input is hard. Most of the simple patterns you see frequently in game dev just don't work well for input, at least at the low level. Typically, for any kind of GUI, you need to have some concepts of focus and possibly also bubbling. The HTML/DOM model here is a good resource. In such a setup, there is a sorted queue of event listeners. For a GUI, this ...


3

If your goal is to have quaternion that expresses rotations, and if you want to do operations with them (for eg. rotation composition by multiplying quaternions or convertion a quaternion to a rotation matrix), they must be unit quaternions, otherwise you may have unexpected results. Quaternion normalization is a relatively costly operation involving ...


2

I see a couple of options: Have the Scene refuse to destroy a GameObject if the ref_count of it's shared_ptr is more than 1. This will oblige your users to take a great care of what happens. This might not be very fun or practical, though. In your GameObject architecture, add a listener pattern: when GameObject A links to GameObject B, tell B that A is ...


2

Amit Patel wrote a great entry all about hexagonal coordinate systems at http://www.redblobgames.com/grids/hexagons/ and I strongly encourage you to read through the whole thing for a deeper understanding. A system he mentions in there that happens to be my personal choice for such systems is the Cube Coordinate system; In this system, three numbers are ...


2

One possible way to decouple this example would be to use a stack of event handlers. Your program can iterate the stack in order, trying each listener until one handles the event: class MenuState : public IKeyListener { ... boolean OnKeyEvent(const KeyEvent& keyCommand) { if (keyCommand.Key == Keys.Enter && keyCommand.IsPressed) ...


2

There are a better solution to get 60fps, set vertical syncronisation (vsync) to true when you create Irrlicht device //Here is the easiest common function to create irrlicht device irr::createDevice ( video::E_DRIVER_TYPE deviceType = video::EDT_SOFTWARE, const core::dimension2d< u32 > & windowSize = (core::dimension2d< u32 >(640, ...


1

One possible solution could be to use weak_ptr. A weak_ptr is like a shared_ptr, except it doesn't keep the object alive. If there are no shared_ptrs pointing to the object, it will be deleted, and then any weak_ptrs will hold NULL. You can use the lock method to get a shared_ptr from a weak_ptr. Example use: shared_ptr<Thingy> s = ...


1

http://unity3d.com/unity/faq What happens if I/we make a game with Unity Personal Edition that earns more than $100,000? To continue using Unity you would have to purchase a Unity 5 Professional Edition license, which you can do in the Online Store or through your regional Unity sales representative.



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