Jamie Slowgrove - MGP Assignment 2 - JAM
 All Classes Namespaces Files Functions Variables Macros
Public Member Functions | Private Member Functions | Private Attributes | List of all members
JAM_Flocking Class Reference

Creates a Flocking object. More...

#include <Flocking.h>

Collaboration diagram for JAM_Flocking:
Collaboration graph

Public Member Functions

 JAM_Flocking (int numberOfBoids, JAM_Texture *texture, int xBoundary, int yBoundary, float maxVel, int screenHeight)
 
 ~JAM_Flocking ()
 
void update (float dt)
 
void draw (SDL_Renderer *renderer)
 
void setRule1 (int applyRule1)
 
void setRule2 (int applyRule2)
 
void setRule3 (int applyRule3)
 

Private Member Functions

JAM_Vec2 rule1 (int index)
 
JAM_Vec2 rule2 (int index)
 
JAM_Vec2 rule3 (int index)
 
JAM_Vec2 roughBoundaries (int index)
 
void limitVelocity (int index)
 

Private Attributes

JAM_TexturewhiteSquare
 
std::vector< JAM_Particle * > boids
 
int applyRule1
 
int applyRule2
 
int applyRule3
 
int xBoundary
 
int yBoundary
 
float maxVel
 
int screenHeight
 

Detailed Description

Creates a Flocking object.

Author
Jamie Slowgrove Reference ~ This code is based upon Pseudo code from https://www.macs.hw.ac.uk/~dwcorne/Teaching/Boids%20Pseudocode.htm

Constructor & Destructor Documentation

JAM_Flocking::JAM_Flocking ( int  numberOfBoids,
JAM_Texture texture,
int  xBoundary,
int  yBoundary,
float  maxVel,
int  screenHeight 
)

Constructs the Flocking object.

Parameters
numberOfBoidsThe number of boids.
textureA pointer to the texture for the boids.
xBoundaryThe rough x boundary of the boids.
yBoundaryThe rough y boundary of the boids.
maxVelThe maximum velocity of the boids.
screenHeightThe screen height.

Here is the call graph for this function:

JAM_Flocking::~JAM_Flocking ( )

Destructs the Flocking object.

Member Function Documentation

void JAM_Flocking::draw ( SDL_Renderer *  renderer)

Draws the Flocking.

Parameters
rendererA pointer to the renderer.
void JAM_Flocking::limitVelocity ( int  index)
private

Limits the Boid velocity.

Parameters
indexThe index of the Boid to test.

Here is the caller graph for this function:

JAM_Vec2 JAM_Flocking::roughBoundaries ( int  index)
private

Applies Boid rough boundaries.

Parameters
indexThe index of the Boid to test.
Returns
The resultant velocity of the boundary.

Here is the caller graph for this function:

JAM_Vec2 JAM_Flocking::rule1 ( int  index)
private

Applies Boid Rule 1.

Parameters
indexThe index of the Boid to test.
Returns
The resultant velocity of the rule.

Here is the caller graph for this function:

JAM_Vec2 JAM_Flocking::rule2 ( int  index)
private

Applies Boid Rule 2.

Parameters
indexThe index of the Boid to test.
Returns
The resultant velocity of the rule.

Here is the caller graph for this function:

JAM_Vec2 JAM_Flocking::rule3 ( int  index)
private

Applies Boid Rule 3.

Parameters
indexThe index of the Boid to test.
Returns
The resultant velocity of the rule.

Here is the caller graph for this function:

void JAM_Flocking::setRule1 ( int  applyRule1)

Setter # Set applyRule1.

Parameters
applyRule1What to do with the rule. (1 == possitve, 0 = neutral, -1 == negative)
void JAM_Flocking::setRule2 ( int  applyRule2)

Setter # Set applyRule2.

Parameters
applyRule2What to do with the rule. (1 == possitve, 0 = neutral, -1 == negative)
void JAM_Flocking::setRule3 ( int  applyRule3)

Setter # Set applyRule3.

Parameters
applyRule3What to do with the rule. (1 == possitve, 0 = neutral, -1 == negative)
void JAM_Flocking::update ( float  dt)

A function that updates the Flocking.

Parameters
dtThe delta time.

Here is the call graph for this function:

Member Data Documentation

int JAM_Flocking::applyRule1
private

What to do with the rule. (1 == possitve, 0 = neutral, -1 == negative)

int JAM_Flocking::applyRule2
private
int JAM_Flocking::applyRule3
private
std::vector<JAM_Particle*> JAM_Flocking::boids
private

A vector of Particle boids.

float JAM_Flocking::maxVel
private

The max velocity.

int JAM_Flocking::screenHeight
private

The screen height.

JAM_Texture* JAM_Flocking::whiteSquare
private

A texture of a white square.

int JAM_Flocking::xBoundary
private

The boundaries of the boids.

int JAM_Flocking::yBoundary
private

The documentation for this class was generated from the following files: