X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=main.c;h=a2bdcbc2d53809b960bc73dd765917ce4b4cef34;hp=db95bb4fae1368da816b1ae9826af1ba008c0fe2;hb=189cc09109987a44aa8af4419a2d106d675a3ea0;hpb=7f2544faabec18fdeb7da3126fc7c842f06c1d43 diff --git a/main.c b/main.c index db95bb4..a2bdcbc 100644 --- a/main.c +++ b/main.c @@ -19,11 +19,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SFont.h" + #ifdef DEBUG #include "debug.h" #endif #include "args.h" +#include "common.h" #include "config.h" #include "file.h" #include "globals.h" @@ -32,17 +44,6 @@ #include "shape.h" #include "sound.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include "SFont.h" - // ************************************* VARS // SDL_Surface global variables SDL_Surface @@ -76,6 +77,7 @@ float shipx = XSIZE/2, shipy = YSIZE/2; // X position, 0..XSIZE 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; @@ -115,6 +117,8 @@ char *data_dir; extern char *optarg; extern int optind, opterr, optopt; +#define TO_TICKS(seconds) ((seconds)*20*opt_gamespeed) + // ************************************* FUNCS float @@ -711,10 +715,16 @@ gameloop() { 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;