* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <argp.h>
+#include <math.h>
+#include <SDL/SDL.h>
+#include <SDL/SDL_image.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SFont.h"
+
#ifdef DEBUG
#include "debug.h"
#endif
#include "args.h"
+#include "common.h"
#include "config.h"
#include "file.h"
#include "globals.h"
#include "shape.h"
#include "sound.h"
-#include <argp.h>
-#include <math.h>
-#include <SDL/SDL.h>
-#include <SDL/SDL_image.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "SFont.h"
-
// ************************************* VARS
// SDL_Surface global variables
SDL_Surface
float shipdx = SCREENDXMIN, shipdy = 0.0; // Change in X position per tick.
float screendx = SCREENDXMIN, screendy = 0.0;
float xscroll, yscroll;
+float back_dist;
float framelen; // this controls the speed of everything that moves.
float bangx, bangy, bangdx, bangdy;
extern char *optarg;
extern int optind, opterr, optopt;
+#define TO_TICKS(seconds) ((seconds)*20*opt_gamespeed)
+
// ************************************* FUNCS
float
tmp /= -25;
tmp = ((screendx * (framelen - 12)) + (tmp * framelen)) / 12;
screendx = -tmp;
- if(screendx < SCREENDXMIN) screendx=SCREENDXMIN;
+
+ // taper off if we would hit the barrier in under 2 seconds.
+ if(back_dist + (screendx - SCREENDXMIN)*TO_TICKS(2) < 0) {
+ screendx = SCREENDXMIN - (back_dist/TO_TICKS(2));
+ }
xscroll = screendx * framelen;
yscroll = screendy * framelen;
+ back_dist += (screendx - SCREENDXMIN)*framelen;
+ if(opt_max_lead >= 0) back_dist = min(back_dist, opt_max_lead);
shipx -= xscroll;
shipy -= yscroll;