JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
reworked ship explosion:
authorJason Woofenden <jason@jasonwoof.com>
Mon, 21 Feb 2005 18:43:57 +0000 (18:43 +0000)
committerJason Woofenden <jason@jasonwoof.com>
Mon, 21 Feb 2005 18:43:57 +0000 (18:43 +0000)
1) bigger
2) ship is gone for longer (much more noticeable)
3) no rocks are left floating ie hardly moving

config.h
main.c

index 0c04fde..8e50c7a 100644 (file)
--- a/config.h
+++ b/config.h
@@ -24,7 +24,8 @@
 #define MAXSPACEDOTS 2000
 #define W 100
 #define M 255
 #define MAXSPACEDOTS 2000
 #define W 100
 #define M 255
-#define BLAST_RADIUS 200 // radius^2 (pixels) which will be cleared of rocks when you die
+#define BLAST_RADIUS 300 // radius^2 (pixels) which will be cleared of rocks when you die
+#define DEAD_PAUSE_LENGTH 40.0
 
 #define MAX_PATH_LEN 1024
 
 
 #define MAX_PATH_LEN 1024
 
diff --git a/main.c b/main.c
index 9b59308..0e0188a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -832,13 +832,32 @@ gameloop() {
                                }
                        } else {
                                if(state == DEAD_PAUSE) {
                                }
                        } else {
                                if(state == DEAD_PAUSE) {
-                                       float blast_radius = BLAST_RADIUS * state_timeout / 20.0;
+                                       float blast_radius;
+                                       int fixonly;
+
+                                       if(state_timeout < DEAD_PAUSE_LENGTH - 20.0) {
+                                               blast_radius = BLAST_RADIUS * 1.3;
+                                               fixonly = 1;
+                                       } else {
+                                               blast_radius = BLAST_RADIUS * (DEAD_PAUSE_LENGTH - state_timeout) / 20.0;
+                                               fixonly = 0;
+                                       }
+
                                        if(shipx < 60) shipx = 60;
                                        for(i = 0; i<MAXROCKS; i++ ) {
                                                float dx, dy, n;
                                                if(rock[i].x <= 0) continue;
                                        if(shipx < 60) shipx = 60;
                                        for(i = 0; i<MAXROCKS; i++ ) {
                                                float dx, dy, n;
                                                if(rock[i].x <= 0) continue;
+
+                                               // This makes it so your explosion from dying magically doesn't leave
+                                               // any rocks that aren't moving much on the x axis. After the first
+                                               // 20 tics, only rocks that are barely moving will be pushed.
+                                               if(fixonly && (!rock[i].dead || rock[i].dx < -4 || rock[i].dx > 3)) {
+                                                       continue;
+                                               }
+
                                                dx = rock[i].x - shipx;
                                                dy = rock[i].y - shipy;
                                                dx = rock[i].x - shipx;
                                                dy = rock[i].y - shipy;
+
                                                n = sqrt(dx*dx + dy*dy);
                                                if(n < blast_radius) {
                                                        n *= 20;
                                                n = sqrt(dx*dx + dy*dy);
                                                if(n < blast_radius) {
                                                        n *= 20;
@@ -944,7 +963,7 @@ gameloop() {
                                }
                                else {
                                        state = DEAD_PAUSE;
                                }
                                else {
                                        state = DEAD_PAUSE;
-                                       state_timeout = 20.0;
+                                       state_timeout = DEAD_PAUSE_LENGTH;
                                        shipdx = 0;
                                        shipdy = 0;
                                }
                                        shipdx = 0;
                                        shipdy = 0;
                                }