OpenFrameworks looking good
Saturday, September 04th, 2010 | Author: dehash
OpenFrameworks is a C++ toolkit designed for creative coding. The Code::Blocks IDE works in a familiar way and the two combine well.
Did a quick port of an old Yugo Flash4 example to AS3 and then to OpenFrameworks C++ to try it out. Very impressed with the toolkit and IDE - if you know some AS3 and some programming you will certainly have a head start. Definitely going to experiment some more with it.
The swf movie is here and the port is below:
C++:
-
#include "testApp.h"
-
-
//--------------------------------------------------------------
-
void testApp::setup(){
-
-
ofSetFrameRate(50);
-
i =0;
-
a = 5;
-
b = 1.66;
-
k = 20;
-
-
for(i=0; i<NBALLS; i++) {
-
ball = &ballArray[i];
-
ball->x = 200+(i*k);
-
ball->y = 400;
-
}
-
-
for(i=0; i<NBALLS; i++) {
-
ball = &ballArray[i];
-
ball->x_value = ball->x;
-
ball->y_value = ball->y;
-
ball->vx = 0;
-
ball->vy = 0;
-
}
-
-
}
-
-
//--------------------------------------------------------------
-
void testApp::update(){
-
-
for(i=1; i<NBALLS; i++) {
-
ball = &ballArray[i];
-
prevBall = &ballArray[(i-1)];
-
ball->vx = (ball->vx + ( prevBall->x_value + k - ball->x_value) /a) /b;
-
ball->vy = (ball->vy + ( prevBall->y_value - ball->y_value) /a) /b;
-
ball->x_value += ball->vx;
-
ball->y_value += ball->vy;
-
}
-
-
ballArray[0].x_value = ballArray[0].x = mouseX;
-
ballArray[0].y_value = ballArray[0].y = mouseY;
-
-
for(i=0; i<NBALLS; i++) {
-
ball = &ballArray[i];
-
ball->x = ball->x_value;
-
ball->y = ball->y_value;
-
}
-
-
}
-
-
//--------------------------------------------------------------
-
void testApp::draw(){
-
-
for(int i=0; i<NBALLS; i++) {
-
ball = &ballArray[i];
-
ball->draw();
-
}
-
-
}


