Пример #1
0
static int l_physics_gc(lua_State* state)
{
    l_physics_PhysicsData* physics = (l_physics_PhysicsData*)lua_touserdata(state, 1);
    cpSpaceFree(physics->physics->space);

    return 0;
}
Пример #2
0
static void
destroy(void)
{
	cpBodyFree(staticBody);
	cpSpaceFreeChildren(space);
	cpSpaceFree(space);
}
Пример #3
0
	Space::~Space() {
		for (auto& shape : shapes) {
			cpSpaceRemoveShape(space, *shape);
		}
		shapes.clear();
		cpSpaceFree(space);
	}
Пример #4
0
static void
destroy(void)
{
	cpBodyFree(rogueBoxBody);
	ChipmunkDemoFreeSpaceChildren(space);
	cpSpaceFree(space);
}
Пример #5
0
static void
destroy(void)
{
	cpBodyFree(tankControlBody);
	cpSpaceFreeChildren(space);
	cpSpaceFree(space);
}
Пример #6
0
static void
destroy(cpSpace *space)
{
	ChipmunkDemoFreeSpaceChildren(space);
	cpBodyFree(planetBody);
	cpSpaceFree(space);
}
Пример #7
0
void eol_level_clear_layer_space(eolLevelLayer *layer)
{
  if (!layer)
  {
    return;
  }
  if (layer->space != NULL)
  {
    cpSpaceFree(layer->space);
  }
  layer->space = cpSpaceNew();
  if (layer->space == NULL)
  {
    eol_logger_message(
      EOL_LOG_ERROR,
      "Unable to create a physics space for new layer!");
    eol_level_delete_layer(layer);
    return;
  }
  layer->space->iterations = _eol_level_clip_iterations;
  layer->space->sleepTimeThreshold = 999999;
  cpSpaceSetEnableContactGraph(layer->space,eolTrue);
  cpSpaceSetCollisionSlop(layer->space, _eol_level_slop);
  cpSpaceSetCollisionBias(layer->space, _eol_level_bias);

}
Пример #8
0
void eol_level_delete_layer(eolLevelLayer * level)
{
  eolBackground *b = NULL;
  GList *s,*e;
  eolSpawn *spawn;
  if (!level)return;
  
  eol_tile_map_free(&level->tileMap);
  
  for (s = level->spawnList; s != NULL; s = s->next)
  {
    if (!s->data)continue;
    spawn = (eolSpawn *)s->data;
    eol_spawn_free(&spawn);
  }
  s = NULL;
  g_list_free(level->spawnList);
  for (s = level->backgrounds; s != NULL; s = s->next)
  {
    if (s->data == NULL)continue;
    b = (eolBackground *)s->data;
    eol_model_free(&b->model);
    free(b);
  }
  s = NULL;
  g_list_free(level->backgrounds);

  for (e = level->entities;e != NULL;e = e->next)
  {
    eol_entity_remove_from_space(e->data);
  }
  g_list_free(level->entities);/*just free our pointers to em, they can delete themselves*/
  if (level->space != NULL)cpSpaceFree(level->space);
}
Пример #9
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);	
	}
Пример #10
0
static void
destroy(void)
{
	cpSpaceFreeChildren(space);
	cpSpaceFree(space);
	
	cpArrayFree(platformInstance.passThruList);
}
Пример #11
0
int lc_space_gc(lua_State *vm){
    lc_space *space = lc_GetSpace(1, vm);
    cpSpaceFree(space->space);
    luaL_unref(vm, LUA_REGISTRYINDEX, space->bodies);
    luaL_unref(vm, LUA_REGISTRYINDEX, space->shapes);
    free(space);
    printf("Delete space: %p\n", lua_touserdata(vm, 1));
}
Пример #12
0
/*
 * main
 */
int main(int argc, char** argv) {


    espace=init();
    SDL_Event event;
    int continuer=1;
    SDL_Init(SDL_INIT_VIDEO);
    ecran=SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);


    
    //char* fichier_dico = "dico.txt";
    //algo_1(fichier_dico, "asdfarbre");
    if (ecran == NULL)
    {
        fprintf(stderr, "Erreur d'initialisation de la SDL");
        exit(EXIT_FAILURE);
    }
     
    SDL_WM_SetCaption("Letter Boule Game !", NULL);
    SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format,0,0,0));
    initPolice();
    initLesBoules(espace);
    boolean refresh=TRUE;
    while (continuer) {
        SDL_WaitEvent(&event);
        switch(event.type) {
            case SDL_QUIT: continuer = 0;
        }
        
        if(refresh)
        {
            affichage();
            refresh=FALSE;
        }    
        if(nbBoules==0)
    {
        SDL_Color white={255,255,255};
        SDL_Surface *game=TTF_RenderText_Solid(police,"GAME OVER" , white);
        SDL_Rect position_game;
        position_game.y=320;
        position_game.x=240;
        SDL_BlitSurface(game, NULL, ecran, &position_game);  
    }
        SDL_Flip(ecran);
        refresh=tracerLigne();
        
        SDL_Flip(ecran);
    }   
    
    cpSpaceFree(espace);
    TTF_CloseFont(police);
    TTF_Quit();
    SDL_Quit();
  
    return (EXIT_SUCCESS);
}
void TestColliderDetector::onExit()
{
	destroyCPBody(armature2->getCPBody());
	destroyCPBody(bullet->getCPBody());
    
	cpSpaceFree(space);
    
	CCLayer::onExit();
}
Пример #14
0
static void
destroy(void)
{
	cpBodyFree(staticBody);
	cpSpaceFreeChildren(space);
	cpSpaceFree(space);
	
	cpArrayFree(playerInstance.groundShapes);
}
Пример #15
0
void world_destroy(World_t *aWorld)
{
    llist_apply(aWorld->entities, (LinkedListApplier_t)&_removeEntityFromWorld, aWorld);
    aWorld->staticEntity->cpBody = NULL;
    world_removeEntity(aWorld, aWorld->staticEntity);
    cpSpaceFree(aWorld->cpSpace), aWorld->cpSpace = NULL;
    obj_release(aWorld->entities), aWorld->entities = NULL;
    obj_release(aWorld->staticEntity), aWorld->staticEntity = NULL;
}
Пример #16
0
/* Cleanup
 * -------
 *
 * Clean up is simple enough. Just destroy the tile
 * image and free the state structure memory.
 */
static void destroy_sample(void* data)
{
    struct state* state = data;
    cleanup_walls(state);
    cleanup_tiles(state);
    destroy_image(state->tile_img);
    cpBodyFree(state->mouse_body);
    cpSpaceFree(state->space);
    free(data);
}
Пример #17
0
	void PhysicsManager::DestroyPhysicsSpace(cpSpace* iSpace)
	{
		SpaceVecIter finded = std::find(mSpaces.begin(), mSpaces.end(), iSpace);

		if(finded != mSpaces.end())
		{
			cpSpaceFree(*finded);
			*finded = 0;
		}
	}
Пример #18
0
void scene_destroy(Scene* scene) {
    cpSpaceFree(scene->space);

    // entities has to be first, because of relation with components
    pool_destroy(scene->entities);
    pool_destroy(scene->transforms);
    pool_destroy(scene->scripts);
    pool_destroy(scene->sprites);
    free(scene);
}
Пример #19
0
PhysicsWorld::~PhysicsWorld()
{
    removeAllJoints(true);
    removeAllBodies();
    if (_cpSpace)
    {
        cpSpaceFree(_cpSpace);
    }
    CC_SAFE_DELETE(_debugDraw);
}
Пример #20
0
ChipmunkTestLayer::~ChipmunkTestLayer()
{
    // manually Free rogue shapes
    for( int i=0;i<4;i++) {
        cpShapeFree( _walls[i] );
    }

    cpSpaceFree( _space );

}
Пример #21
0
 void CDynamics2DEngine::Destroy() {
    /* Empty the physics model map */
    for(CDynamics2DModel::TMap::iterator it = m_tPhysicsModels.begin();
        it != m_tPhysicsModels.end(); ++it) {
       delete it->second;
    }
    m_tPhysicsModels.clear();
    /* Get rid of the physics space */
    cpSpaceFree(m_ptSpace);
    cpBodyFree(m_ptGroundBody);
 }
Пример #22
0
void GameScene::onExit()
{
	Scene::onExit();
	this->unscheduleUpdate();

	for (auto& shape : shapes)
		cpShapeFree(shape);
	shapes.clear();

	cpSpaceRemoveCollisionHandler(space, collisionTypeBall, collisionTypeWall);
	cpSpaceFree(space);
}
Пример #23
0
//destroy all allocated memory of cpSpace struct
void core_destroy_space ( cpSpace *space ) {
    
    //iterates through shapes and bodies and destroys them
    cpSpaceEachShape ( space, &core_destroy_shape, (void *) NULL );
    cpSpaceEachBody ( space, &core_destroy_body, (void *) NULL );
    
    destroy_body_info(space->staticBody->data);
    
    game_info_destroy ( (GameInfo *) space->data );
    //frees space
    cpSpaceFree ( space );
}
Пример #24
0
void
cpHastySpaceFree(cpSpace *space)
{
    cpHastySpace *hasty = (cpHastySpace *)space;

    HaltThreads(hasty);

    pthread_mutex_destroy(&hasty->mutex);
    pthread_cond_destroy(&hasty->cond_work);
    pthread_cond_destroy(&hasty->cond_resume);

    cpSpaceFree(space);
}
Пример #25
0
ChipmunkTestLayer::~ChipmunkTestLayer()
{
#if CC_ENABLE_CHIPMUNK_INTEGRATION
    // manually Free rogue shapes
    for( int i=0;i<4;i++) {
        cpShapeFree( _walls[i] );
    }

    cpSpaceFree( _space );

    Device::setAccelerometerEnabled(false);
#endif
}
Пример #26
0
PhysicsWorld::~PhysicsWorld()
{
    removeAllJoints(true);
    removeAllBodies();
    if (_cpSpace)
    {
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
		cpSpaceFree(_cpSpace);
#else
		cpHastySpaceFree(_cpSpace);
#endif 
    }
    CC_SAFE_RELEASE_NULL(_debugDraw);
}
Пример #27
0
	~Phys()
	{
		for (std::vector<Ship*>::iterator it = ship_list.begin(); it != ship_list.end(); ++it)
		{
			cpSpaceRemoveShape(space, (*it)->cpshape);
			cpSpaceRemoveBody(space, (*it)->body);
			delete *it;
		}
		ship_list.clear();
		for (std::vector<Shell*>::iterator it = shell_list.begin(); it != shell_list.end(); ++it)
		{
			cpSpaceRemoveShape(space, (*it)->cpshape);
			cpSpaceRemoveBody(space, (*it)->body);
			delete *it;
		}
		shell_list.clear();
		cpSpaceFree(space);
	}
Пример #28
0
int main (int argc, char **argv) {
    cpSpace *space = cpSpaceNew();
    cpSpaceSetGravity(space, cpv(0, GRAVITY));
    cpEnableSegmentToSegmentCollisions();
    
    cpShape *ground = cpSpaceAddShape(space, cpSegmentShapeNew(space->staticBody, cpv(0, 5), cpv(10, -5), 0));
    cpShapeSetFriction(ground, 0.3);
    
    cpBody *drawing = drawing_new(2, 7, 0);
    drawing = drawing_update(space, drawing, 3, 8);
    drawing = drawing_update(space, drawing, 3, 9);
    drawing = drawing_update(space, drawing, 2, 9);
    //cpBody *drawing = drawing_new(0, 0, 0);
    //drawing = drawing_update(space, drawing, 2, 0);
    //drawing = drawing_update(space, drawing, 2, 2);
    //drawing = drawing_update(space, drawing, 0, 2);
    print_positions(drawing);
    
    //drawing_activate(drawing);
    //print_positions(drawing);
    
    cpVect vel, pos;
    int i = 0;
    for(cpFloat time = 0; time < 2; time += TIMESTEP){
        pos = cpBodyGetPos(drawing);
        vel = cpBodyGetVel(drawing);
        
        printf( "Time = %2.2f Position = (%2.2f, %2.2f) Velocity = (%2.2f, %2.2f)\n",
            time, pos.x, pos.y, vel.x, vel.y);
        cpSpaceStep(space, TIMESTEP);
        
        i++;
        if (i == 20) {
            drawing_activate(space, drawing);
            print_positions(drawing);
        }
    }
    print_positions(drawing);
    
    free_body_full(drawing);
    cpShapeFree(ground);
    cpSpaceFree(space);
    return EXIT_SUCCESS;
}
Пример #29
0
void physics_deinit()
{
    PhysicsInfo *info;

    /* clean up draw stuff */
    glDeleteProgram(program);
    glDeleteBuffers(1, &vbo);
    glDeleteVertexArrays(1, &vao);

    /* remove all bodies, shapes */
    entitypool_foreach(info, pool)
        _remove(info);

    /* deinit cpSpace */
    cpSpaceFree(space);

    /* deinit pools, maps */
    entitymap_free(debug_draw_map);
    entitypool_free(pool);
}
Пример #30
0
int main (int argc, char *argv[]){
  Gui *gui = (Gui *)malloc(sizeof(Gui));;
  gui->space = cpSpaceNew();
  gui->current_body = NULL;
  cpSpaceSetGravity(gui->space, cpv(0, GRAVITY));
  cpEnableSegmentToSegmentCollisions();
  
  gtk_init(&argc, &argv); 

  initialize_window(gui);

  initialize_client(gui);  
  
  pthread_t t1;
  int iret1 = pthread_create(&t1, NULL, client_recv1, gui);

  gtk_main();
  
  cpSpaceFree(gui->space);
  free(gui);
  return 0;
}