JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
made bang dots hit rocks, removed blast_rocks function.
authorJoshua Grams <josh@qualdan.com>
Sun, 26 Mar 2006 11:16:30 +0000 (11:16 +0000)
committerJoshua Grams <josh@qualdan.com>
Sun, 26 Mar 2006 11:16:30 +0000 (11:16 +0000)
main.c
rocks.c

diff --git a/main.c b/main.c
index d2627f2..f7de24e 100644 (file)
--- a/main.c
+++ b/main.c
@@ -190,6 +190,7 @@ draw_bang_dots(SDL_Surface *s)
        int first_i, last_i;
        uint16_t *pixels, *pixel, c;
        int row_inc = s->pitch/sizeof(uint16_t);
+       Sprite *hit;
 
        pixels = (uint16_t *) s->pixels;
        first_i = -1;
@@ -211,7 +212,14 @@ draw_bang_dots(SDL_Surface *s)
                }
 
                // check collisions
-               if(pixel_collides(bdot[i].x, bdot[i].y)) { bdot[i].active = 0; continue; }
+               if((hit = pixel_collides(bdot[i].x, bdot[i].y))) {
+                       if(hit->type != SHIP) { // they shouldn't hit the ship, but they do
+                               bdot[i].active = 0;
+                               hit->dx += ENGINE_DOT_WEIGHT * bdot[i].life * bdot[i].dx / sprite_mass(hit);
+                               hit->dy += ENGINE_DOT_WEIGHT * bdot[i].life * bdot[i].dy / sprite_mass(hit);
+                               continue;
+                       }
+               }
 
                pixel = pixels + row_inc*(int)(bdot[i].y) + (int)(bdot[i].x);
                if(bdot[i].c) c = bdot[i].c; else c = heatcolor[(int)(bdot[i].life)*3];
diff --git a/rocks.c b/rocks.c
index ed98cac..5f637e0 100644 (file)
--- a/rocks.c
+++ b/rocks.c
@@ -201,27 +201,3 @@ draw_rocks(void)
        int i;
        for(i=0; i<MAXROCKS; i++) draw_sprite(SPRITE(&rocks[i]));
 }
-
-void
-blast_rocks(float x, float y, float radius)
-{
-       int i;
-       Sprite *r;
-       float dx, dy, n;
-
-       for(i=0; i<MAXROCKS; i++) {
-               if(!rocks[i].flags) continue;
-               r = SPRITE(&rocks[i]);
-               if(r->x <= 0) continue;
-
-               dx = r->x - x;
-               dy = r->y - y;
-
-               n = sqrt(dx*dx + dy*dy);
-               if(n < radius) {
-                       n *= 15;
-                       r->dx += 54.0*dx/n;
-                       r->dy += 54.0*dy/n;
-               }
-       }
-}