Ejemplo n.º 1
0
static void
destroy(void)
{
	cpBodyFree(tankControlBody);
	cpSpaceFreeChildren(space);
	cpSpaceFree(space);
}
Ejemplo n.º 2
0
static void
destroy(void)
{
	cpBodyFree(staticBody);
	cpSpaceFreeChildren(space);
	cpSpaceFree(space);
}
Ejemplo n.º 3
0
	static void physics_thread()
	{	
		/* Now initialize the physics engine. */
		cpInitChipmunk();
		space = cpSpaceNew();	
	
		do
		{
			/* But here we do care about the elapsed time. */
			synchronize(&oldtime /*,&server_elapsed*/);

			simple_lock(&physics_lock);

			physics(world, space);
			cpSpaceHashEach(space->activeShapes, &draw_player, NULL);
			//cpSpaceHashEach(space->staticShapes, &draw_static, NULL);

			simple_unlock(&physics_lock);

			if(to_remove_array.length > 0)
				lDestroy(&to_remove_array, remove_unused);
		}
		while(!physics_exit_time);

		lFree(&to_remove_array);
		cpSpaceFreeChildren(space);
		cpSpaceFree(space);	
	}
Ejemplo n.º 4
0
static void
destroy(void)
{
	cpSpaceFreeChildren(space);
	cpSpaceFree(space);
	
	cpArrayFree(platformInstance.passThruList);
}
Ejemplo n.º 5
0
static void
destroy(void)
{
	cpBodyFree(staticBody);
	cpSpaceFreeChildren(space);
	cpSpaceFree(space);
	
	cpArrayFree(playerInstance.groundShapes);
}
Ejemplo n.º 6
0
wyChipmunk::~wyChipmunk() {
	cpSpaceFreeChildren(m_space);
	cpSpaceFree(m_space);
}
Ejemplo n.º 7
0
int main(int argc, char **argv) {
    int i, fileMenuId;
    cpArray *constraints;

    domino_t *dom;
    projectile_t *pj;

    if (!Sys_CreateWindow("Atlas2D", 800, 600, false)) {
        Sys_KillWindow();
        return 0;
    }

    atlInitAtlas();

#ifdef __APPLE__
/*
    fileMenuId = Sys_CreateMenu("File");
    Sys_AppendMenuItem(fileMenuId, "Open...", openCB);
    Sys_AppendMenuSeparator(fileMenuId);
    Sys_AppendMenuItem(fileMenuId, "Save", saveCB);
    Sys_AppendMenuItem(fileMenuId, "Save As...", saveAsCB);
*/
#endif

    g_FontBase = Sys_LoadBmpFont("Helvetica");

    cpInitChipmunk();
    initSpace();

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    while (!atlEscapePressed) {
        update();

        glClear(GL_COLOR_BUFFER_BIT);

        if (editorBody) {
            drawEditorPalette();
        }

        render_cannon(g_Cannon);
        atlDrawPhysicsObject(platforms[0]->shape, g_Space);

/*
        cpSpaceHashEach(g_Space->staticShapes,
                        (cpSpaceHashIterator)atlDrawPhysicsObject, g_Space);
        cpSpaceHashEach(g_Space->activeShapes,
                        (cpSpaceHashIterator)atlDrawPhysicsObject, g_Space);
*/

        for (i = 0; i < MAX_DOMINOES; ++i) {
            dom = g_Dominoes[i];
            if (!dom) continue;
            render_domino(dom);
        }

        for (i = 0; i < g_Cannon->ai; ++i) {
            pj = g_Cannon->ammo[i];
            if (!pj) continue;
            render_projectile(pj);
        }

        constraints = g_Space->constraints;
        for (i = 0; i < constraints->num; ++i) {
            atlDrawConstraint((cpConstraint *)constraints->arr[i]);
        }

        Sys_SwapBuffers();
        Sys_EventLoop();
    }

    /* has to be called before the cpSpaceFree* functions because it removes
     * bodies and shapes itself */
    FreeDominoes();

    cpSpaceFreeChildren(g_Space);
    cpSpaceFree(g_Space);

    for (i = 0; i < MAX_PLATFORMS; ++i) {
        if (platforms[i])
            free(platforms[i]);
    }

    if (g_Cannon)
        free(g_Cannon);

    atlFreeImages();
    atlFreeBmpFont(g_FontBase);

    Sys_KillWindow();

    return 0;
}
Ejemplo n.º 8
0
/*!
    @method ~KRSimulator2D
    Destructor
 */
KRSimulator2D::~KRSimulator2D()
{
    cpBodyFree((cpBody*)mCPStaticBody);
	cpSpaceFreeChildren((cpSpace*)mCPSpace);
    cpSpaceFree((cpSpace*)mCPSpace);
}