/* This file was generated by scramble.py. */
#line 1 "src/particle.py"
#include "particle.h"
#line 11
static Particle particles [1024];
static int particle_n;
#line 14
void particle_smoke(float x, float y, int n) {
    for (int jn = 0; jn < n; jn += 1) {
        int i = particle_n;
        Particle * p = particles + i;
        particle_n++;
        particle_n &= 1023;
        p->x = x;
        p->y = y;
        p->t = tile_by_id(tile_by_name("cloud"));
        p->end_time = game_global ()->time + 120;
        float a = land_rnd(0, 2 * pi);
        p->dx = cos(a) * 5;
        p->dy = sin(a) * 2;
        p->ax = 0;
        p->ay = 0;
        p->angle = 0;
        p->add = 0;
    }
}
#line 32
void particle_sparkle(float x, float y, int n) {
    for (int jn = 0; jn < n; jn += 1) {
        int i = particle_n;
        Particle * p = particles + i;
        particle_n++;
        particle_n &= 1023;
        p->x = x;
        p->y = y;
        p->t = tile_by_id(tile_by_name("sparkle"));
        p->end_time = game_global ()->time + 120;
        p->dx = land_rnd(- 2, 2);
        p->dy = - 5;
        p->ax = 0;
        p->ay = 0.1;
        p->angle = land_rnd(0, 2 * pi);
        p->add = 1;
    }
}
#line 49
void particle_tear(float x, float y, int dx, int dy, float ay) {
    for (int jn = 0; jn < 1; jn += 1) {
        int i = particle_n;
        Particle * p = particles + i;
        particle_n++;
        particle_n &= 1023;
        p->x = x;
        p->y = y;
        p->t = tile_by_id(tile_by_name("tear"));
        p->end_time = game_global ()->time + 90;
        p->dx = dx;
        p->dy = dy;
        p->ax = 0;
        p->ay = ay;
        p->angle = 0;
        p->add = 1;
    }
}
void particle_draw_all(Camera * cam) {
#line 69
    Game * game = game_global();
    for (int i = 0; i < 1024; i += 1) {
        Particle * p = particles + i;
        if (game->time > p->end_time) {
            continue;
        }
#line 74
        float x = camera_x(game->camera, p->x);
        float y = camera_y(game->camera, p->y);
        float a = (p->end_time - game->time) / 60.0;
        if (a > 1) {
            a = 1;
        }
#line 79
        if (p->add) {
#line 79
            land_blend(LAND_BLEND_ADD);
        }
#line 79
        else {
            land_blend(LAND_BLEND_TINT);
        }
#line 81
        land_image_draw_rotated_tinted(p->t->pic, x - p->t->w / 2, y - p->t->h / 2, p->angle, a, a, a, a);
    }
    land_blend(LAND_BLEND_TINT);
}
void particle_move_all(void) {
    Game * game = game_global();
    for (int i = 0; i < 1024; i += 1) {
        Particle * p = particles + i;
        if (game->time > p->end_time) {
            continue;
        }
#line 91
        p->x += p->dx;
        p->y += p->dy;
        p->dx += p->ax;
        p->dy += p->ay;
    }
}
/* This file was generated by scramble.py. */
