Esempio n. 1
0
int main()
{
    Physics p;
    Achievements a;
    p.update();
    a.update();
    return 0;
}
void HelloParticlesApp::update() {
	
	// update physics
	timer->stop();
	double dt = timer->getSeconds();
	timer->start();

	float mouseX = getMousePos().x;
	float mouseY = getMousePos().y;
	attractor->setPosition(Vec3f(mouseX, mouseY, 0));
	
	physics->update(dt);
}
Esempio n. 3
0
int main()
{
   Physics app;
   // DIYmain app;

    if (app.startup() == false)
    {
        return -1;
    }

    while (app.update() == true)
    {
        app.draw();
    }

    app.shutdown();

    return 0;
}
void FlockingParticlesApp::update() {
	
	// update physics
	timer->stop();
	double dt = timer->getSeconds();
	timer->start();
	
	float mouseX = (float)getMousePos().x;
	float mouseY = (float)getMousePos().y;
	attractor->setPosition(Vec3f(mouseX, mouseY, 0));
	
	physics->update(dt);
	
	// copy particle positions into vbo
	gl::VboMesh::VertexIter iter = vboParticles.mapVertexBuffer();
	for(vector<Particle*>::iterator p = physics->particles.begin(); p != physics->particles.end(); p++) {
		if(!(*p)->isAlive) continue;
		iter.setPosition((*p)->position.x, (*p)->position.y, (*p)->position.z);
		++iter;
	}
}
Esempio n. 5
0
int main(int argc, char* args[])
{
	SDL_Init(SDL_INIT_EVERYTHING);
	Renderer scene;
	Interface input;
	Physics logic;
	Resource *init_obj;
	init_obj = new Resource;
	scene.objects = init_obj;
	input.objects = init_obj;
	logic.objects = init_obj;
	while(init_obj->game_on){
		scene.update();
		input.update();
		logic.update();
	}
	delete init_obj;
	SDL_Quit();

	return 0;
}
void FlockingParticlesApp::testParticleCreation() {
	
	printf("running testParticleCreation\n");
	timer->stop();
	timer->start();
	
	BasicSpace* space = new BasicSpace(Vec3f::zero(), Vec3f(getWindowWidth(), getWindowHeight(), 0));
	Physics* physics = new Physics(space);
	
	Emitter* emitter = new Emitter(physics);
	physics->emitter = emitter;
	emitter->setPosition(space->getCenter());
	emitter->setInterval(0.0001);
	emitter->setRate(50000);
	emitter->setMax(50 * 1000);
	
	int numIterations = 10;
	for(int i=0; i<numIterations; i++) {
		physics->update(0.016f);
		//physics->createParticle();
	}
	
	timer->stop();
	printf("%f s \n", timer->getSeconds());
}