void _warzone_break_blocks_around(warzone *p_wz, int new_x, int new_y,
        shape shape_belt, shape shape_body) {
    int sx, sy, belt_pixel, body_pixel;
    block b;
    for (sy = shape_belt.min.y; sy <= shape_belt.max.y; sy++) {
        for (sx = shape_belt.min.x; sx <= shape_belt.max.x; sx++) {
            body_pixel = shape_is_solid_o(shape_body, sx, sy);
            //            belt_pixel = shape_is_solid_o(shape_belt, sx, sy);

            if (body_pixel) {
                b = tunneler_map_get_block(&p_wz->map, new_x + sx, new_y + sy);
                if (block_is_breakable(b)) {
                    int bfr = warzone_set_block(p_wz, new_x + sx, new_y + sy, BLOCK_EMPTY);
                }
            }


        }
    }
}
void _engine_uwz_update_projectiles(engine *p, game_room *p_gr, warzone *p_wz) {
    int i, new_x, new_y, clear = 0;
    block b;
    projectile *p_proj;
    tank *p_target;
    for (i = 0; i < p_wz->projectiles_size; i++) {
        p_proj = p_wz->projectiles + i;
        if (p_proj->direction == DIRECTION_0) {
            continue;
        }
        new_x = p_proj->location.x += G_DIRECTIONS[p_proj->direction].x;
        new_y = p_proj->location.y += G_DIRECTIONS[p_proj->direction].y;

        b = tunneler_map_get_block(&p_wz->map, new_x, new_y);
        if (block_is_obstacle(b)) {
            clear = 1;
        } else if (block_is_breakable(b)) {
            clear = 1;
            warzone_set_block(p_wz, new_x, new_y, BLOCK_EMPTY);
        } else {
            p_target = _engine_uwz_find_tank_hit(p_wz, p_proj);
            if (p_target != NULL) {
                if (tank_reduce_hitpoints(p_target) == 0) {
                    engine_gameroom_tank_destroyed(p, p_gr, p_target);
                }

                clear = 1;
            }
        }

        if (clear) {
            projectile_clear(p_proj);
            network_command_prepare(p->p_cmd_out, NCT_GAME_PROJ_REM);
            network_command_append_byte(p->p_cmd_out, i);
            engine_bc_command(p, p_gr, p->p_cmd_out);
        }

    }
}
Esempio n. 3
0
static uint8_t attempt_to_break_block(int x, int y)
{
    int ret = 0;
    if (block_is_breakable(get_map_block(x,y))){
        remove_map_block(x, y);
        Mix_PlayChannel(-1, mix_blkboom, 0);
        ret = 1;

        int i;
        for(i = 0; i < 10; i++){
            Particle *p = malloc(sizeof(Particle));
            p->x = x;
            p->y = y;
            p->vx = rand() % 5 - 2.5;
            p->vy = rand() % 5 - 2.5;
            p->color = SDL_MapRGB(main_screen->format, 0, 0, 0);
            p->draw = particle_draw_chunky;
            p->update = particle_update_normal;
            p->timeout = rand() % 100;
            list_append(particles, p);
        }
    }
    return ret;
}