3 double b_x1
, b_y1
, b_x2
, b_y2
;
5 typedef struct plistitem_s
{
10 plistitem_t parts
[NO_PARTS
];
12 void SetParticleBoundingBox(double x
, double y
, double xx
, double yy
)
20 void AddParticle(Particle
*p
)
24 for (i
= 0; i
< NO_PARTS
; i
++) {
25 if (parts
[i
].p
== 0) {
33 void UpdateParticle(Particle
*p
, double dt
)
35 p
->x
= p
->x
+ dt
* p
->vx
;
36 p
->vx
= p
->vx
* (1.0 - p
->fx
*dt
) + dt
* p
->ax
;
37 p
->y
= p
->y
+ dt
* p
->vy
;
38 p
->vy
= p
->vy
* (1.0 - p
->fy
*dt
) + dt
* p
->ay
;
39 p
->t
= p
->t
+ dt
* p
->vt
;
40 p
->vt
= p
->vt
* (1.0 - p
->ft
*dt
) + dt
* p
->at
;
43 void WhiteFunc(double temp
, SDL_Color
*c
)
45 static SDL_Color white
={255,255,255,255};
46 if (c
!= 0) memcpy(c
, &white
, sizeof(SDL_Color
));
49 void QueueDrawPart(Particle
*p
)
56 WhiteFunc(p
->t
, &color
);
58 QueueDrawSpriteColorize(p
->s
, p
->x
, p
->y
, p
->z
, color
);
61 void RemoveParticle(plistitem_t
*a
)
68 void UpdateAndQueueDrawParticles(double dt
)
72 for (i
=0; i
<NO_PARTS
; i
++){
78 UpdateParticle(a
->p
, dt
);
80 if (a
->p
->t
<= 0.0 || a
->p
->x
< b_x1
|| a
->p
->y
< b_y1
|| (a
->p
->x
+ a
->p
->s
->width
) > b_x2
|| (a
->p
->x
+ a
->p
->s
->width
) > b_x2
) {