Exemple #1
0
void SurfaceObject::scroll(int x, int y, int wrap)
{
    SurfaceImage * image = selected_image;
    image->wrap = wrap != 0;
    if (use_image_blit) {
        vector<SurfaceBlit>::iterator it;
        for (it = blit_images.begin(); it != blit_images.end(); it++) {
            SurfaceBlit & img = *it;
            img.scroll_x += x;
            img.scroll_y += y;
            wrap_pos(img.scroll_x, img.x, img.image->width, image->width);
            wrap_pos(img.scroll_y, img.y, img.image->height, image->height);
        }
        return;
    } else if (image == NULL || image->handle == NULL)
        return;
    image->scroll_x = (image->scroll_x + x) % image->handle->width;
    image->scroll_y = (image->scroll_y + y) % image->handle->height;
}
Exemple #2
0
void read_positions(FILE *fp,
                    struct gadget_header_t *header,
                    float *buf,
                    struct gadget_particle_t *particles)
{
    uint32_t dummy;
    fread(&dummy, sizeof(dummy), 1, fp);

    uint32_t len = header->npart[1];
    fread(buf, sizeof(*buf), 3 * len, fp);

    for (uint32_t i = 0; i < len; i++) {
        memcpy(particles[i].pos, buf + i * 3, sizeof(*buf) * 3);
        wrap_pos(particles[i].pos, header);
    }

    fread(&dummy, sizeof(dummy), 1, fp);
    return;
}