Esempio n. 1
0
/** Frees the object and all resources attached to it (even the animation, if it is owned by the object)
  * \param obj Object handle
  */
void object_free(object *obj) {
    if(obj->free != NULL) {
        obj->free(obj);
    }
    player_free(obj);
    if(obj->cur_animation_own == OWNER_OBJECT) {
        animation_free(obj->cur_animation);
        free(obj->cur_animation);
    }
    if (obj->custom_str) {
        free(obj->custom_str);
    }
    obj->cur_surface = NULL;
    obj->cur_animation = NULL;
}
Esempio n. 2
0
void
ship_free(SHIP *ship)
{
  LIST *head;

  if(ship->explosion)
    animation_free(ship->explosion);

  head = list_first(ship->missiles);
  while(head) {
    missile_free((MISSILE *) head->data);
    head = head->next;
  }

  list_free(ship->missiles);
  free(ship->position);
  free(ship->velocity);
  free(ship);

  ship = NULL;
}
Esempio n. 3
0
void scene_free(scene *scene) {
    if(!scene) return;
    
    // Deinit scene
    if(scene->deinit != NULL) {
        scene->deinit(scene);
    }
    
    // Release background
    texture_free(&scene->background);
    
    // Free players
    iterator it;
    animationplayer *tmp = 0;
    list_iter_begin(&scene->child_players, &it);
    while((tmp = iter_next(&it)) != NULL) {
        animationplayer_free(tmp);
    }
    list_iter_begin(&scene->root_players, &it);
    while((tmp = iter_next(&it)) != NULL) {
        animationplayer_free(tmp);
    }
    list_free(&scene->child_players);
    list_free(&scene->root_players);
    
    // Free animations
    animation *ani = 0;
    array_iter_begin(&scene->animations, &it);
    while((ani = iter_next(&it)) != 0) {
        animation_free(ani);
        free(ani);
    }
    array_free(&scene->animations);

    // XXX do NOT free hars/controllers here!

    // Free BK
    sd_bk_delete(scene->bk);
}
Esempio n. 4
0
/** Sets an animation for object. It will automatically start playing on first tick.
  * \param obj Object handle
  * \param ani Animation to attach
  */
void object_set_animation(object *obj, animation *ani) {
    if(obj->cur_animation != NULL && obj->cur_animation_own == OWNER_OBJECT) {
        animation_free(obj->cur_animation);
        free(obj->cur_animation);
    }
    if (obj->custom_str != NULL) {
        free(obj->custom_str);
    }
    obj->custom_str = NULL;
    obj->cur_animation = ani;
    obj->cur_animation_own = OWNER_EXTERNAL;
    player_reload(obj);

    // Debug texts
    if(obj->cur_animation->id == -1) {
        DEBUG("Custom object set to (x,y) = (%f,%f).",
            obj->pos.x, obj->pos.y);
    } else {
        /*DEBUG("Animation object %d set to (x,y) = (%f,%f) with \"%s\".", */
            /*obj->cur_animation->id,*/
            /*obj->pos.x, obj->pos.y,*/
            /*str_c(&obj->cur_animation->animation_string));*/
    }
}
Esempio n. 5
0
static void
remove_explosion(ANIMATION *explosion)
{
  asteroids.explosions = list_remove(asteroids.explosions, explosion);
  animation_free(explosion);
}