Commit 1a3d3354 authored by Kevin Dang's avatar Kevin Dang

added some comments to the code

parent 5ca5cf98
......@@ -12,14 +12,14 @@
class flocking {
public:
flocking(float _x, float _y, float _z);
float x;
float y;
float z;
flocking(float _x, float _y, float _z); // constructor takes in x y z for sphere positions
float x; // x
float y; // y
float z; // z
void display();
void update(ofVec3f _tempPos);
ofVec3f location, velocity, acceleration, dir, staticTarget;
float topSpeed;
float topSpeed;
};
......
......@@ -10,24 +10,24 @@
#include "lightBalls.h"
lightBalls::lightBalls() {
for (int i = 0; i < 5; i++) {
Flocking.push_back(flocking(0,0,0));
for (int i = 0; i < 5; i++) { // only create 5 light spheres in our world
Flocking.push_back(flocking(0,0,0)); // set initial position to 0,0,0
}
}
void lightBalls::update(ofVec3f _tempPos) {
for (int i = 0; i < Flocking.size(); i++) {
Flocking[i].update(_tempPos);
Flocking[i].update(_tempPos); // apply the update function to all elements in the vector
}
for (int i = 0; i < Flocking.size(); i++) {
for (int i = 0; i < Flocking.size(); i++) { // this controls the movement and direction of the sphere objects
Flocking[i].dir.set(Flocking[i].staticTarget.x - Flocking[i].location.x,Flocking[i].staticTarget.y - Flocking[i].location.y);
}
}
void lightBalls::display() {
for (int i = 0; i < 5; i++) {
for (int i = 0; i < 5; i++) { // displays all elements in the vector
Flocking[i].display();
}
}
......
......@@ -9,14 +9,14 @@
#ifndef lightBalls_h
#define lightBalls_h
#include "ofMain.h"
#include "flocking.h"
#include "flocking.h" // include the flocking class to use in this lightBall object
class lightBalls {
public:
lightBalls();
void display();
lightBalls();
void display();
void update(ofVec3f _tempPos);
vector <flocking> Flocking;
vector <flocking> Flocking; // create vector of Flocking class
};
#endif /* lightBalls_h */
......@@ -5,6 +5,8 @@
int main( ){
ofSetupOpenGL(1024,768,OF_FULLSCREEN); // <-------- setup the GL context
// set the screen to full screen mode
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
......
......@@ -11,9 +11,9 @@
class ofApp : public ofBaseApp {
public:
void setup();
void update();
void draw();
void setup();
void update();
void draw();
void camRotate();
......
......@@ -11,18 +11,18 @@
populateSmallSphere::populateSmallSphere() {
for (int i = 0; i < 600; i++) {
sphereObjects.push_back(smallSphereObject(0,0,0));
sphereObjects.push_back(smallSphereObject(0,0,0)); // populate the world with 600 small sphere objects
}
for (int i = 0; i < 5; i++) {
boxObject.push_back(boxObjects(0,0,0));
boxObject.push_back(boxObjects(0,0,0)); // populate the world with box objects
}
}
void populateSmallSphere::display() {
for (int i = 0; i < sphereObjects.size(); i++) {
sphereObjects[i].display();
sphereObjects[i].display(); // display the small sphere objects in the world
}
for (int i = 0; i < boxObject.size(); i++) {
boxObject[i].display();
boxObject[i].display(); // display the box object
}
}
\ No newline at end of file
......@@ -9,14 +9,15 @@
#ifndef populateSmallSphere_h
#define populateSmallSphere_h
#include "ofMain.h"
#include "smallSphereObject.h"
#include "smallSphereObject.h" // include the smallSphereObject.h class
class populateSmallSphere {
public:
populateSmallSphere();
void display();
vector <smallSphereObject> sphereObjects;
// create vector of smallSphereObject and boxObjects
vector <smallSphereObject> sphereObjects;
vector <boxObjects> boxObject;
};
......
......@@ -10,21 +10,23 @@
#define smallSphereObject_h
#include "ofMain.h"
// this is the class for the static sphere objects, used to populate the world
class smallSphereObject {
protected:
float x;
float y;
float z;
ofVec3f location;
public:
explicit smallSphereObject(float _x, float _y, float _z);
ofVec3f location; // create vector for location variable which takes in the floats x,y,z
public:
explicit smallSphereObject(float _x, float _y, float _z); // the explicit keyword allows for constructor inheritance
virtual void display();
};
class boxObjects: public smallSphereObject {
class boxObjects: public smallSphereObject { // boxObject inherits smallSphereObject
public:
using smallSphereObject::smallSphereObject;
using smallSphereObject::smallSphereObject; // inherits the constructor from base class
void display();
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment