Game Development Reference
In-Depth Information
once constructed makes it very quick and easy to search through as you can remove
entire branches of the tree by determining which ones are visible.
A three-level Quad-Tree
In our game we won't need any culling because if anything leaves the screen it will
be destroyed.
Implementation
To get started with the implementation, we need to consider the code we already
have. The texture class implemented in the previous chapters hold the image we
want to render, but it also contains a position to render at. Normally this might not
be an issue but if we want to cache the texture, we need to separate that position
variable so that we can re-use the texture object. To do this, we'll create a new class
named sprite, and move the position property to that class, as well as add a shared
pointer to a texture so that the sprite can be linked with a loaded image. For referen-
ce, here are the class definitions for the Sprite and Texture .
class Sprite
{
private:
std::shared_ptr<Texture> _tex;
public:
XMFLOAT2 Position;
float Rotation;
XMFLOAT2 Scale;
Search WWH ::




Custom Search