JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
w00t! Finally rearranged the scroll equations so they make sense to me.
authorJoshua Grams <josh@qualdan.com>
Fri, 8 Jul 2005 21:22:32 +0000 (21:22 +0000)
committerJoshua Grams <josh@qualdan.com>
Fri, 8 Jul 2005 21:22:32 +0000 (21:22 +0000)
Also moved reset_rocks() call to init_rocks() from main().

config.h
main.c
rocks.c

index 641234a..5c7729c 100644 (file)
--- a/config.h
+++ b/config.h
@@ -7,6 +7,9 @@
 #define XSIZE 640
 #define YSIZE 480
 
+#define XSCROLLTO (XSIZE/3)
+#define YSCROLLTO (YSIZE/2)
+
 #define SCREENDXMIN 7.5
 
 // image file containing font for score stuff.
diff --git a/main.c b/main.c
index 58d68d7..c32feb3 100644 (file)
--- a/main.c
+++ b/main.c
@@ -613,16 +613,10 @@ gameloop() {
                        shipy += shipdy*t_frame;
 
                        // SCROLLING
-                       tmp = shipy - (YSIZE / 2);
-                       tmp += shipdy * 25;
-                       tmp /= -25;
-                       tmp = ((screendy * (t_frame - 12)) + (tmp * t_frame)) / 12;
-                       screendy = -tmp;
-                       tmp = shipx - (XSIZE / 3);
-                       tmp += shipdx * 25;
-                       tmp /= -25;
-                       tmp = ((screendx * (t_frame - 12)) + (tmp * t_frame)) / 12;
-                       screendx = -tmp;
+                       tmp = (shipy-YSCROLLTO)/25 + (shipdy-screendy);
+                       screendy += tmp * t_frame/12;
+                       tmp = (shipx-XSCROLLTO)/25 + (shipdx-screendx);
+                       screendx += tmp * t_frame/12;
 
                        // taper off if we would hit the barrier in under 2 seconds.
                        if(back_dist + (screendx - SCREENDXMIN)*TO_TICKS(2) < 0) {
@@ -753,7 +747,6 @@ main(int argc, char **argv) {
                return 1;
        }
 
-       reset_rocks();
        gameloop();
 
        return 0;
diff --git a/rocks.c b/rocks.c
index d2fda29..0b54b04 100644 (file)
--- a/rocks.c
+++ b/rocks.c
@@ -50,6 +50,7 @@ init_rocks(void)
                NULLERROR(surf_rock[i] = SDL_DisplayFormat(temp));
                get_shape(surf_rock[i], &rock_shapes[i]);
        }
+       reset_rocks();
        return 0;
 }