Permalink
Browse files

initial commit

  • Loading branch information...
nathankoch committed Jul 31, 2010
0 parents commit d3f77cae8c83d22085c3749ecb75fad68b19300f
@@ -0,0 +1,5 @@
+.DS_Store
+*.mode1v3
+*.pbxuser
+*.app
+bin/
No changes.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.openFrameworks</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+</dict>
+</plist>
@@ -0,0 +1,16 @@
+#include "ofMain.h"
+#include "testApp.h"
+#include "ofAppGlutWindow.h"
+
+//========================================================================
+int main( ){
+
+ ofAppGlutWindow window;
+ ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context
+
+ // this kicks off the running of my app
+ // can be OF_WINDOW or OF_FULLSCREEN
+ // pass in width and height too:
+ ofRunApp( new testApp());
+
+}
@@ -0,0 +1,61 @@
+/*
+ * Particle.cpp
+ * ParticleSystem
+ *
+ * Created by nathan_laptop on 7/17/10.
+ * Copyright 2010 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "ofxParticle.h"
+
+ofxParticle::ofxParticle() {
+ loc = ofxVec2f(ofRandom( 0, ofGetWidth()), ofRandom(0, ofGetHeight()));
+ vel = ofxVec2f(0, 0 );
+ accel = ofxVec2f(0, 0 );
+ mass = 1.0;
+ bounce = 1.0;
+ topSpeed = 20;
+ radius = 1;
+ color = ofColor();
+}
+
+void ofxParticle::update() {
+ checkEdges();
+ vel += accel;
+ vel.limit(topSpeed);
+ loc += vel;
+ accel = ofxVec2f(0, 0 );
+}
+
+void ofxParticle::addForce( ofxVec2f force) {
+ force = force / mass;
+ accel += force;
+}
+
+void ofxParticle::draw() {
+ ofSetColor(color.r, color.g, color.b, color.a);
+ ofRect(loc.x, loc.y, radius, radius);
+}
+
+void ofxParticle::checkEdges() {
+ int wh = ofGetHeight();
+ int ww = ofGetWidth();
+
+ if (loc.y > wh) {
+ vel.y *= -bounce;
+ loc.y = wh - 2;
+ }
+ if (loc.y < 1) {
+ vel.y *= -bounce;
+ loc.y = 2;
+ }
+ if (loc.x > ww) {
+ vel.x *= -bounce;
+ loc.x = ww - 2;
+ }
+ if (loc.x < 1) {
+ vel.x *= -bounce;
+ loc.x = 2;
+ }
+}
@@ -0,0 +1,37 @@
+/*
+ * Particle.h
+ * ParticleSystem
+ *
+ * Created by nathan_laptop on 7/17/10.
+ * Copyright 2010 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#pragma once
+#include "ofMain.h"
+#include "ofxVectorMath.h"
+
+class ofxParticle {
+public:
+
+ // constructors
+ ofxParticle();
+
+ // methods
+ void update();
+ void addForce(ofxVec2f force);
+ void draw();
+ void checkEdges();
+
+ // properties
+ ofxVec2f loc;
+ ofxVec2f vel;
+ ofxVec2f accel;
+
+ float mass;
+ float topSpeed;
+ float bounce;
+ float radius;
+
+ ofColor color;
+};
@@ -0,0 +1,53 @@
+/*
+ * ofxParticleSystem.cpp
+ * ofxParticleSystem
+ *
+ * Created by nathan_laptop on 7/17/10.
+ * Copyright 2010 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "ofxParticleSystem.h"
+
+ofxParticleSystem::ofxParticleSystem() {
+}
+
+ofxParticleSystem::ofxParticleSystem(int initialAmount) {
+ addParticles(initialAmount);
+}
+
+void ofxParticleSystem::update() {
+ for ( list<ofxParticle>::iterator p = particles.begin(); p != particles.end(); ++p) {
+ p->update();
+ }
+}
+
+void ofxParticleSystem::addForce(ofxVec2f force) {
+ for ( list<ofxParticle>::iterator p = particles.begin(); p != particles.end(); ++p) {
+ p->addForce(force);
+ }
+}
+
+void ofxParticleSystem::draw() {
+ for ( list<ofxParticle>::iterator p = particles.begin(); p != particles.end(); ++p) {
+ p->draw();
+ }
+}
+
+void ofxParticleSystem::addParticles( int amount ) {
+ for (int i = 0; i < amount; i++) {
+ particles.push_back( ofxParticle() );
+ }
+}
+
+void ofxParticleSystem::removeParticles( int amount ) {
+ for (int i = 0; i < amount; i++) {
+ if (!particles.empty()) {
+ particles.pop_back();
+ }
+ }
+}
+
+int ofxParticleSystem::numParticles() {
+ return particles.size();
+}
@@ -0,0 +1,31 @@
+/*
+ * ofxParticleSystem.h
+ * ofxParticleSystem
+ *
+ * Created by nathan_laptop on 7/17/10.
+ * Copyright 2010 __MyCompanyName__. All rights reserved.
+ *
+ */
+#pragma once
+#include "ofxParticle.h"
+#include "ofxVectorMath.h"
+
+class ofxParticleSystem {
+public:
+ // constructors
+ ofxParticleSystem();
+ ofxParticleSystem(int initialAmount);
+
+ // methods
+ void update();
+ void addForce(ofxVec2f force);
+ void draw();
+
+ void addParticles(int amount);
+ void removeParticles(int amount);
+
+ int numParticles();
+
+ // properties
+ std::list<ofxParticle> particles;
+};
@@ -0,0 +1,52 @@
+#include "testApp.h"
+
+//--------------------------------------------------------------
+void testApp::setup(){
+
+}
+
+//--------------------------------------------------------------
+void testApp::update(){
+
+}
+
+//--------------------------------------------------------------
+void testApp::draw(){
+
+}
+
+//--------------------------------------------------------------
+void testApp::keyPressed(int key){
+
+}
+
+//--------------------------------------------------------------
+void testApp::keyReleased(int key){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseMoved(int x, int y ){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseDragged(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mousePressed(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseReleased(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::windowResized(int w, int h){
+
+}
+
@@ -0,0 +1,24 @@
+#ifndef _TEST_APP
+#define _TEST_APP
+
+
+#include "ofMain.h"
+
+class testApp : public ofBaseApp{
+
+ public:
+ void setup();
+ void update();
+ void draw();
+
+ void keyPressed (int key);
+ void keyReleased(int key);
+ void mouseMoved(int x, int y );
+ void mouseDragged(int x, int y, int button);
+ void mousePressed(int x, int y, int button);
+ void mouseReleased(int x, int y, int button);
+ void windowResized(int w, int h);
+
+};
+
+#endif

0 comments on commit d3f77ca

Please sign in to comment.