Tag Info

Hot answers tagged

6

I need a tutorial that does not skip to explain any lines of code. It should also include different independent objects moving/rotating (most tutorials use only one object), as well as imported 3d objects Arcysnthesis is the best modern OpenGL tutorial I know of, using imported objects doesn't add much to the use of the API, and it's usually API ...


5

Keep Bullet functionality in the Bullet class. This just sounded like nails against a chalkboard to me: During the iteration, it checks what type of object it is, such as Bullet etc. Once it has checked this, it will calculate where the bullet should move to next based upon the Velocity property. Aaagh. D: It's not the base Entity class' ...


3

Wavefront obj files usually are combined with material files (.mat) which define the textures used. The meshes of a model are divided in different material groups. Each material tells you which textures to use and other information of the mesh. In your case, there are separate meshes on the model. These meshes are head, body and hands. They all have their ...


3

I like to use a callback based input manager. The Player class calls the static register method of the input manager with the input to register (either some hard coded values like W or an alias like Forward) and a method to call back when the event happens. In Java this will probably be programmed with an anonymous overloaded object of a callback class. ...


3

How about instead of threads or continuous looping, you use an event system to notify listeners (people who care about when the timer/action is 'finished'). Edit: This pattern is called the observer pattern. There are many ways to implement the function callback system, including delegates and function pointers. It is up to you which one you use, though ...


3

Do you really need two ways of deleting an object? If there is no concrete reason for an object to be able to destroy itself, you could scrap the WorldObject::removeFromWorld() method entirely. Otherwise, your compiler will probably allow you to call a method that destroys the caller, but I wouldn't say this is a good idea. Consider what could happen if you ...


2

As far as I know, if you don't use the object after it's destroyed there is no problem (otherwise you will be accessing a deleted object which is probably undefined behaviour). You could avoid the trouble of managing the memory by having std::unique_ptr<WorldObject> instead of WorldObject* and you would remove from the map simply by calling ...


2

You can split this into two stages: Firstly generate some pinecones with such minimum distance between them that you need: On second stage add some pinecones next to those placed already: That way you will have have some single pinecones and some pinecones clumps, but all of those will be separated well apart. You can tweak 1st stage to use slightly ...


1

Personally, I use a spin on the first option you listed. When checking if A collides with B, however, a series of disqualifiers (or a singular disqualifier) can be used to reduce the computation required for each iteration of your collision checker. For example: if((b.y >= a.y && b.y <= (a.y + a.h)) || ((b.y+b.h) >= a.y && (b.y+b.h) ...


1

You seem not to have a TextMesh component in your game object, and you are not checking if GetComponent method has returned any. You can add it once at runtime if it doesn't exist: var text = gameObject.GetComponent(TextMesh); if( text == null ) { text = gameObject.AddComponent(TextMesh); } Or to make it better, you can make var text a private class ...


1

Simple Answer Use a class to load the original prefab from Resources.Load(string prefabPath, typeof(GameObject)); Store this returned prefab into a resource pool class by path key. For instance: Dictionary<string, GameObject> prefabLookup; You can then grab the original prefab anytime you need it. Use a helper method to automatically load at ...


1

In my case, I went about a lot of this through composition (more precisely through the Strategy Pattern). I built an interface, and made LinearMovement and CircularMovement classes. My friend later added a ParabolicMovement class. Any of these can be provided to a game object at will; you can swap them out at any time. The result is that the function that ...


1

There's many ways to solve this. One way is, yes, to keep the resources attached to the game objects. Each game object would store a handle to its material and its mesh(es). Another approach is to keep a separate hierarchy/list of scene nodes. Each game object would just hold a reference to the scene node that represents the object visually. The scene node ...


1

A standard "tween" algorithm usually works by simplifying a more general hermite spline function, to eliminate the necessity of manually providing initial and terminating velocity values. But if you wish to be able to switch from one tween to another, you can no longer do that, and you'll need to use a full, non-simplified spline calculation. Here's some ...


1

In modern OpenGL you can almost totally seperate rendered object from each other, using different vaos and shader programs. And even the implementation of one object can be separated into many abstraction layers. For example, if you want to implement a terrain, you could define a TerrainMesh whose constructor creates the vertices and indices for the ...


1

This is entirely subjective to the design requirements of your game but, generally speaking, usually most systems use an event-based system where objects register for events. It allows for a pretty flexible system where you can design anything from HID input to timers to trigger events. If you would like to see a pretty strong example of how this can be ...



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