-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Mastering Android NDK
By :
To implement the above mentioned behaviors, we will consider the following class hierarchy:

A single boid is represented by an instance of the clBoid class, which holds a pointer to an instance of iBehaviour. The iBehavior interface contains a single member function, GetControl(), which calculates the instant force acting on a boid. Since the force magnitude might depend on a boid's state, we pass a raw non-owning pointer to clBoid into GetControl():
class iBehaviour: public iIntrusiveCounter
{
public:
virtual vec2 GetControl( float dt, clBoid* Boid ) = 0;
};Let's consider the clBoid class itself. It contains m_Pos and m_Vel fields, which hold the current position and velocity of the boid, respectively. These values are two-dimensional vectors, but the whole structure can be extended to 3D logic using three-component vectors:
class clBoid: public iActor
{
public:
vec2 m_Pos;
vec2 m_Vel;The m_Angle field is the boid's instant orientation, and it...
Change the font size
Change margin width
Change background colour