- double theta, theta2, dx, dy, adx, ady;
-
- // Don't create fresh engine dots when
- // the game is not being played and a demo is not beng shown
- if(state != GAMEPLAY) return;
-
- for(i = 0; i<newdots; i++) {
- if(dotptr->active == 0) {
- theta = rnd()*M_PI*2;
- theta2 = rnd()*M_PI*2;
-
- dx = cos(theta) * fabs(cos(theta2));
- dy = sin(theta) * fabs(cos(theta2));
- adx = fabs(dx);
- ady = fabs(dy);
-
-
- dotptr->active = 1;
- dotptr->x = shipx + surf_ship->w/2 + (rnd()-0.5)*3;
- dotptr->y = shipy + surf_ship->h/2 + (rnd()-0.5)*3;
-
- switch(m) {
- case 0:
- dotptr->x -= 14;
- dotptr->dx = -20*adx + shipdx;
- dotptr->dy = 2*dy + shipdy;
- dotptr->life = 60 * adx;
- break;
- case 1:
- dotptr->dx = 2*dx + shipdx;
- dotptr->dy = -20*ady + shipdy;
- dotptr->life = 60 * ady;
- break;
- case 2:
- dotptr->x += 14;
- dotptr->dx = 20*adx + shipdx;
- dotptr->dy = 2*dy + shipdy;
- dotptr->life = 60 * adx;
- break;
- case 3:
- dotptr->dx = 2*dx + shipdx;
- dotptr->dy = 20*ady + shipdy;
- dotptr->life = 60 * ady;
- break;
- }
- dotptr++;
- if(dotptr-edot >= MAXENGINEDOTS) {
- dotptr = edot;
+ Sprite *hit;
+
+ for(i = 0; i<MAXENGINEDOTS; i++) {
+ if(!edot[i].active) continue;
+
+ edot[i].x += (edot[i].dx - screendx)*ticks;
+ edot[i].y += (edot[i].dy - screendy)*ticks;
+ edot[i].life -= t_frame*3;
+ if(edot[i].life < 0 || edot[i].x<0 || edot[i].x >= XSIZE || edot[i].y < 0 || edot[i].y >= YSIZE) {
+ edot[i].active = 0;
+ }
+
+ // check collisions
+ if((hit = pixel_collides(edot[i].x, edot[i].y))) {
+ if(hit->type != SHIP) { // they shouldn't hit the ship, but they do
+ edot[i].active = 0;
+ hit->dx += ENGINE_DOT_WEIGHT * edot[i].life * edot[i].dx / sprite_mass(hit);
+ hit->dy += ENGINE_DOT_WEIGHT * edot[i].life * edot[i].dy / sprite_mass(hit);
+ continue;