JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
started factoring out global t_frame
authorJoshua Grams <josh@qualdan.com>
Tue, 13 Jun 2006 19:49:29 +0000 (19:49 +0000)
committerJoshua Grams <josh@qualdan.com>
Tue, 13 Jun 2006 19:49:29 +0000 (19:49 +0000)
dust.c
dust.h
globals.h
main.c
rocks.c
rocks.h
sprite.c
sprite.h

diff --git a/dust.c b/dust.c
index b336696..5ee9e20 100644 (file)
--- a/dust.c
+++ b/dust.c
@@ -27,11 +27,11 @@ init_dust(void)
 }
 
 void
 }
 
 void
-move_dust(void)
+move_dust(float ticks)
 {
        int i;
 {
        int i;
-       float xscroll = screendx * t_frame;
-       float yscroll = screendy * t_frame;
+       float xscroll = screendx * ticks;
+       float yscroll = screendy * ticks;
        for(i=0; i<N_DUST_MOTES; i++) {
                motes[i].x -= xscroll / (1.3 + motes[i].z);
                motes[i].y -= yscroll / (1.3 + motes[i].z);
        for(i=0; i<N_DUST_MOTES; i++) {
                motes[i].x -= xscroll / (1.3 + motes[i].z);
                motes[i].y -= yscroll / (1.3 + motes[i].z);
diff --git a/dust.h b/dust.h
index 984587b..5241a60 100644 (file)
--- a/dust.h
+++ b/dust.h
@@ -11,7 +11,7 @@
 #define MAX_DUST_DEPTH 2
 
 void init_dust(void);
 #define MAX_DUST_DEPTH 2
 
 void init_dust(void);
-void move_dust(void);
+void move_dust(float ticks);
 void draw_dust(SDL_Surface *);
 
 #endif // VOR_DUST_H
 void draw_dust(SDL_Surface *);
 
 #endif // VOR_DUST_H
index a16e9f8..24e016e 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -50,10 +50,6 @@ extern char *initerror;
 
 extern float screendx, screendy;
 
 
 extern float screendx, screendy;
 
-// All movement is based on t_frame.
-// All speeds are pixels/tick, with 20 ticks per second.
-extern float t_frame;  // length of this frame (in ticks = 1/20th second)
-
 extern int score;
 extern int g_easy;
 extern float fadetimer, faderate;
 extern int score;
 extern int g_easy;
 extern float fadetimer, faderate;
diff --git a/main.c b/main.c
index e3a0f83..e6449fe 100644 (file)
--- a/main.c
+++ b/main.c
@@ -343,7 +343,7 @@ drawdots(SDL_Surface *s) {
                }
        }
 
                }
        }
 
-       move_dust();
+       move_dust(t_frame);
 
        SDL_LockSurface(s);
        draw_dust(s);
 
        SDL_LockSurface(s);
        draw_dust(s);
@@ -676,7 +676,7 @@ gameloop() {
                                }
                        }
 
                                }
                        }
 
-                       new_rocks();
+                       new_rocks(t_frame);
 
                        // SCROLLING
                        tmp = (ship.y+ship.dy*t_frame-YSCROLLTO)/25 + (ship.dy-screendy);
 
                        // SCROLLING
                        tmp = (ship.y+ship.dy*t_frame-YSCROLLTO)/25 + (ship.dy-screendy);
@@ -694,7 +694,7 @@ gameloop() {
                        bangx += (bangdx - screendx)*t_frame;
                        bangy += (bangdy - screendy)*t_frame;
 
                        bangx += (bangdx - screendx)*t_frame;
                        bangy += (bangdy - screendy)*t_frame;
 
-                       move_sprites();
+                       move_sprites(t_frame);
 
 
                        // BOUNCE off left or right edge of screen
 
 
                        // BOUNCE off left or right edge of screen
diff --git a/rocks.c b/rocks.c
index 9384fe0..c404305 100644 (file)
--- a/rocks.c
+++ b/rocks.c
@@ -129,7 +129,7 @@ weighted_rnd_range(float min, float max) {
 }
 
 void
 }
 
 void
-new_rocks(void)
+new_rocks(float ticks)
 {
        int i, type;
        struct rock *r;
 {
        int i, type;
        struct rock *r;
@@ -138,7 +138,7 @@ new_rocks(void)
        float rmax[4];
 
        if(nrocks < final_rocks) {
        float rmax[4];
 
        if(nrocks < final_rocks) {
-               nrocks_timer += t_frame;
+               nrocks_timer += ticks;
                if(nrocks_timer >= nrocks_inc_ticks) {
                        nrocks_timer -= nrocks_inc_ticks;
                        nrocks++;
                if(nrocks_timer >= nrocks_inc_ticks) {
                        nrocks_timer -= nrocks_inc_ticks;
                        nrocks++;
@@ -148,7 +148,7 @@ new_rocks(void)
        rock_sides(ti, rmin, rmax);
 
        // increment timers
        rock_sides(ti, rmin, rmax);
 
        // increment timers
-       for(i=0; i<4; i++) rtimers[i] += ti[i]*t_frame;
+       for(i=0; i<4; i++) rtimers[i] += ti[i]*ticks;
 
        // generate rocks
        for(i=0; i<4; i++) {
 
        // generate rocks
        for(i=0; i<4; i++) {
diff --git a/rocks.h b/rocks.h
index 1fbff53..baa462d 100644 (file)
--- a/rocks.h
+++ b/rocks.h
@@ -3,7 +3,7 @@
 void load_rocks(void);
 void reset_rocks(void);
 
 void load_rocks(void);
 void reset_rocks(void);
 
-void new_rocks(void);
+void new_rocks(float ticks);
 void draw_rocks(void);
 
 void blast_rocks(float x, float y, float radius);
 void draw_rocks(void);
 
 void blast_rocks(float x, float y, float radius);
index 447e482..36ca546 100644 (file)
--- a/sprite.c
+++ b/sprite.c
@@ -128,11 +128,11 @@ reset_sprites(void)
 }
 
 void
 }
 
 void
-move_sprite(Sprite *s)
+move_sprite(Sprite *s, float ticks)
 {
        if(s->flags & MOVE) {
 {
        if(s->flags & MOVE) {
-               s->x += (s->dx - screendx)*t_frame;
-               s->y += (s->dy - screendy)*t_frame;
+               s->x += (s->dx - screendx)*ticks;
+               s->y += (s->dy - screendy)*ticks;
        }
 }
 
        }
 }
 
@@ -148,7 +148,7 @@ sort_sprite(Sprite *s)
 }
 
 void
 }
 
 void
-move_sprites(void)
+move_sprites(float ticks)
 {
        int sq;
        Sprite **head;
 {
        int sq;
        Sprite **head;
@@ -158,7 +158,7 @@ move_sprites(void)
                head=&sprites[set][sq];
                while(*head) {
                        Sprite *s = remove_sprite(head);
                head=&sprites[set][sq];
                while(*head) {
                        Sprite *s = remove_sprite(head);
-                       move_sprite(s); sort_sprite(s);
+                       move_sprite(s, ticks); sort_sprite(s);
                }
        }
        set = 1-set;  // switch to other set of sprites.
                }
        }
        set = 1-set;  // switch to other set of sprites.
index 3cb2c0e..0bca1af 100644 (file)
--- a/sprite.h
+++ b/sprite.h
@@ -40,8 +40,8 @@ void collisions(void);
 void init_sprites(void);
 void reset_sprites(void);
 void add_sprite(Sprite *s);
 void init_sprites(void);
 void reset_sprites(void);
 void add_sprite(Sprite *s);
-void move_sprite(Sprite *s);
-void move_sprites(void);
+void move_sprite(Sprite *s, float ticks);
+void move_sprites(float ticks);
 
 Sprite *collides(Sprite *s);
 Sprite * pixel_collides(float x, float y);
 
 Sprite *collides(Sprite *s);
 Sprite * pixel_collides(float x, float y);