示例#1
0
void object_dynamic_tick(object *obj) {
    obj->age++;

    if(obj->attached_to != NULL) {
        object_set_pos(obj, object_get_pos(obj->attached_to));
        object_set_direction(obj, object_get_direction(obj->attached_to));
    }

    // Check if object still needs to be halted
    if(obj->halt_ticks > 0) {
        obj->halt_ticks--;
        obj->halt = (obj->halt_ticks > 0);
    }

    // Run animation player
    if(obj->cur_animation != NULL && obj->halt == 0) {
        for(int i = 0; i < obj->stride; i++)
            player_run(obj);
    }

    // Tick object implementation
    if(obj->dynamic_tick != NULL) {
        obj->dynamic_tick(obj);
    }

    // Handle screen shakes, V & H
    if(obj->sprite_state.screen_shake_vertical > 0) {
        obj->gs->screen_shake_vertical = obj->sprite_state.screen_shake_vertical * 4;
        obj->sprite_state.screen_shake_vertical = 0;
    }
    if(obj->sprite_state.screen_shake_horizontal > 0) {
        obj->gs->screen_shake_horizontal = obj->sprite_state.screen_shake_horizontal * 4;
        obj->sprite_state.screen_shake_horizontal = 0;
    }
}
示例#2
0
static void start_decorate_update (line_decorate_t *dec, line_path_t *path) {
    double dist, width;
    point_unit_t *pu = path->pts->head;
    point_t tmp;
    point_t *st = pu->data;
    point_t *ed = (pu->next) ? pu->next->data : pu->data;

    dist = hypot (st->x - ed->x, st->y - ed->y);

    width = line_decorate_get_width (dec) / 2;

    tmp.x = st->x * ((dist - width) / dist) + ed->x * (width / dist);

    tmp.y = st->y * ((dist - width) / dist) + ed->y * (width / dist);

    object_set_pos (dec, &tmp);

    line_decorate_set_angle (dec, atan2(ed->y - st->y, ed->x - st->x));
    
    width = line_decorate_get_width (dec) - 2;

    tmp.x = st->x * ((dist - width) / dist) + ed->x * (width / dist);

    tmp.y = st->y * ((dist - width) / dist) + ed->y * (width / dist);

    *st = tmp;   
}