1 /* Variations on RockDodger
2 * Space Rocks copyright (C) 2001 Paul Holt <pad@pcholt.com>
4 * Project fork 2004, Jason Woofenden and Joshua Grams.
5 * (a whole bunch of modifications and project rename)
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #include <SDL/SDL_image.h>
43 #define CONDERROR(a) if((a)) {initerror = strdup(SDL_GetError());return 1;}
44 #define NULLERROR(a) CONDERROR((a) == NULL)
46 // ************************************* STRUCTS
50 int dead; // has been blown out of the way
51 // to make room for a new ship appearing.
57 // Bang dots have the same colour as shield dots.
58 // Bang dots get darker as they age.
59 // Some are coloured the same as the ex-ship.
61 Uint16 c; // when zero, use heatcolor[bangdotlife]
62 float life; // When reduced to 0, set active = 0
64 float decay;// Amount by which to reduce life each time dot is drawn
67 // Engine dots stream out the back of the ship, getting darker as they go.
70 // The life of an engine dot
71 // is a number starting at between 0 and 50 and counting backward.
72 float life; // When reduced to 0, set active = 0
75 // Space dots are harmless background items
76 // All are active. When one falls off the edge, another is created at the start.
81 // ************************************* VARS
82 // SDL_Surface global variables
84 *surf_screen, // Screen
85 *surf_b_variations, // "variations" banner
86 *surf_b_on, // "on" banner
87 *surf_b_rockdodger, // "rockdodger" banner
88 *surf_b_game, // Title element "game"
89 *surf_b_over, // Title element "over"
90 *surf_ship, // Spaceship element
91 *surf_life, // Indicator of number of ships remaining
92 *surf_rock[NROCKS], // THE ROCKS
93 *surf_font_big; // The big font
95 struct shape rock_shapes[NROCKS];
99 // Structure global variables
100 struct enginedots edot[MAXENGINEDOTS], *dotptr = edot;
101 struct rock_struct rock[MAXROCKS], *rockptr = rock;
102 struct bangdots bdot[MAXBANGDOTS], *bdotptr = bdot;
103 struct spacedot sdot[MAXSPACEDOTS];
105 // Other global variables
107 char *initerror = "";
109 struct shape shipshape;
110 float shipx,shipy = 240.0; // X position, 0..XSIZE
111 float shipdx,shipdy; // Change in X position per tick.
112 float rockrate,rockspeed;
113 float movementrate; // this controls the speed of everything that moves.
117 int nships,score,initticks,ticks_since_last, last_ticks;
121 int sound_flag = 1, music_flag = 0;
122 int tail_plume = 0; // display big engine at the back?
123 int friction = 0; // should there be friction?
124 float fadetimer = 0, faderate;
126 int pausedown = 0, paused = 0;
128 // bangdot start (bd1) and end (bd2) position:
129 int bd1 = 0, bd2 = 0;
139 enum states state = TITLE_PAGE;
140 float state_timeout = 600.0;
144 "Press SPACE to start",
145 "http://qualdan.com/vor/"
148 int bangdotlife, nbangdots;
149 Uint16 heatcolor[W*3];
153 extern int optind, opterr, optopt;
155 float dist_sq(float x1, float y1, float x2, float y2)
157 return (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
160 // ************************************* FUNCS
164 return (float)random()/(float)RAND_MAX;
170 for(i = 0; i<MAXENGINEDOTS; i++) {
178 for(i = 0; i<MAXSPACEDOTS; i++) {
181 sdot[i].x = rnd()*(XSIZE-5);
182 sdot[i].y = rnd()*(YSIZE-5);
188 intensity = (int)(r*180 + 70);
189 sdot[i].color = SDL_MapRGB(surf_screen->format,intensity,intensity,intensity);
195 makebangdots(int xbang, int ybang, int dx, int dy, SDL_Surface *s, int power) {
197 // TODO - stop generating dots after a certain amount of time has passed, to cope with slower CPUs.
198 // TODO - generate and display dots in a circular buffer
205 begin_generate = SDL_GetTicks();
208 rawpixel = (Uint16 *) s->pixels;
210 //for(n = 0; n <= power/2; n++) {
214 for(x = 0; x<s->w; x++) {
215 for(y = 0; y<s->h; y++) {
216 c = rawpixel[s->pitch/2*y + x];
217 if(c && c != s->format->colorkey) {
219 theta = rnd()*M_PI*2;
223 bdot[bd2].dx = (power/50.0)*45.0*cos(theta)*r + dx;
224 bdot[bd2].dy = (power/50.0)*45.0*sin(theta)*r + dy;
225 bdot[bd2].x = x + xbang;
226 bdot[bd2].y = y + ybang;
228 // Replace the last few bang dots with the pixels from the exploding object
229 bdot[bd2].c = (endcount>0)?c:0;
230 bdot[bd2].life = 100;
231 bdot[bd2].decay = rnd()*3 + 1;
232 bdot[bd2].active = 1;
237 // If the circular buffer is filled, who cares? They've had their chance.
238 //if(bd2 == bd1-1) goto exitloop;
244 if(SDL_GetTicks() - begin_generate > 7) endcount++;
247 SDL_UnlockSurface(s);
252 draw_bang_dots(SDL_Surface *s) {
256 rawpixel = (Uint16 *) s->pixels;
260 for(i = bd1; (bd1 <= bd2)?(i<bd2):(i >= bd1 && i < bd2); last_i = ++i) {
264 if(bdot[i].x <= 0 || bdot[i].x >= XSIZE || bdot[i].y <= 0 || bdot[i].y >= YSIZE) {
265 // If the dot has drifted outside the perimeter, kill it
273 rawpixel[(int)(s->pitch/2*(int)(bdot[i].y)) + (int)(bdot[i].x)] = bdot[i].c ? bdot[i].c : heatcolor[(int)(bdot[i].life*3)];
274 bdot[i].life -= bdot[i].decay;
275 bdot[i].x += bdot[i].dx*movementrate;
276 bdot[i].y += bdot[i].dy*movementrate + yscroll;
296 draw_space_dots(SDL_Surface *s) {
299 rawpixel = (Uint16 *) s->pixels;
301 for(i = 0; i<MAXSPACEDOTS; i++) {
305 rawpixel[(int)(s->pitch/2*(int)sdot[i].y) + (int)(sdot[i].x)] = sdot[i].color;
306 sdot[i].x += sdot[i].dx*movementrate;
307 sdot[i].y += yscroll;
308 if(sdot[i].y > YSIZE) {
310 } else if(sdot[i].y < 0) {
320 draw_engine_dots(SDL_Surface *s) {
323 rawpixel = (Uint16 *) s->pixels;
325 for(i = 0; i<MAXENGINEDOTS; i++) {
327 edot[i].x += edot[i].dx*movementrate;
328 edot[i].y += edot[i].dy*movementrate + yscroll;
329 if((edot[i].life -= movementrate*3)<0 || edot[i].y<0 || edot[i].y>YSIZE) {
331 } else if(edot[i].x<0 || edot[i].x>XSIZE) {
335 heatindex = edot[i].life * 6;
336 //rawpixel[(int)(s->pitch/2*(int)(edot[i].y)) + (int)(edot[i].x)] = lifecolor[(int)(edot[i].life)];
337 rawpixel[(int)(s->pitch/2*(int)(edot[i].y)) + (int)(edot[i].x)] = heatindex>3*W ? heatcolor[3*W-1] : heatcolor[heatindex];
344 create_engine_dots(int newdots) {
346 double theta,r,dx,dy;
348 if(!tail_plume) return;
350 if(state == GAMEPLAY) {
351 for(i = 0; i<newdots*movementrate; i++) {
352 if(dotptr->active == 0) {
353 theta = rnd()*M_PI*2;
359 dotptr->x = shipx + surf_ship->w/2-14;
360 dotptr->y = shipy + surf_ship->h/2 + (rnd()-0.5)*5-1;
361 dotptr->dx = 10*(dx-1.5) + shipdx;
362 dotptr->dy = 1*dy + shipdy;
363 dotptr->life = 45 + rnd(1)*5;
366 if(dotptr-edot >= MAXENGINEDOTS) {
375 create_engine_dots2(int newdots, int m) {
377 double theta, theta2, dx, dy, adx, ady;
379 // Don't create fresh engine dots when
380 // the game is not being played and a demo is not beng shown
381 if(state != GAMEPLAY) return;
383 for(i = 0; i<newdots; i++) {
384 if(dotptr->active == 0) {
385 theta = rnd()*M_PI*2;
386 theta2 = rnd()*M_PI*2;
388 dx = cos(theta) * fabs(cos(theta2));
389 dy = sin(theta) * fabs(cos(theta2));
395 dotptr->x = shipx + surf_ship->w/2 + (rnd()-0.5)*3;
396 dotptr->y = shipy + surf_ship->h/2 + (rnd()-0.5)*3;
401 dotptr->dx = -20*adx + shipdx;
402 dotptr->dy = 2*dy + shipdy;
403 dotptr->life = 60 * adx;
406 dotptr->dx = 2*dx + shipdx;
407 dotptr->dy = -20*ady + shipdy;
408 dotptr->life = 60 * ady;
412 dotptr->dx = 20*adx + shipdx;
413 dotptr->dy = 2*dy + shipdy;
414 dotptr->life = 60 * adx;
417 dotptr->dx = 2*dx + shipdx;
418 dotptr->dy = 20*ady + shipdy;
419 dotptr->life = 60 * ady;
423 if(dotptr-edot >= MAXENGINEDOTS) {
431 drawdots(SDL_Surface *s) {
435 // Draw the background stars aka space dots
438 // Draw the score when playing the game or whn the game is freshly over
439 if(1 || state == GAMEPLAY || state == DEAD_PAUSE || state == GAME_OVER ) {
440 SDL_UnlockSurface(s);
442 snprintscore_line(topline, 50, score);
443 SFont_Write(s,g_font,XSIZE-250,0,topline);
448 // Draw all the engine dots
451 // Create more engine dots comin out da back
452 if(!gameover) create_engine_dots(200);
454 // Create engine dots out the side we're moving from
455 for(m = 0; m<4; m++) {
456 if(maneuver & 1<<m) { // 'maneuver' is a bit field
457 create_engine_dots2(80,m);
461 // Draw all outstanding bang dots
462 //if(bangdotlife-- > 0)
465 SDL_UnlockSurface(s);
468 char a[MAX_PATH_LEN];
470 init(int fullscreen) {
476 // Where are our data files?
477 if(!find_files()) exit(1);
478 read_high_score_table();
481 // Initialize SDL with audio and video
482 if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0) {
484 printf ("Can't open sound, starting without it\n");
488 atexit(SDL_CloseAudio);
489 sound_flag = init_sound();
492 // Initialize with video only
493 CONDERROR(SDL_Init(SDL_INIT_VIDEO) != 0);
499 // Attempt to get the required video size
500 flag = SDL_DOUBLEBUF | SDL_HWSURFACE;
501 if(fullscreen) flag |= SDL_FULLSCREEN;
502 surf_screen = SDL_SetVideoMode(XSIZE,YSIZE,16,flag);
504 // Set the title bar text
505 SDL_WM_SetCaption("Variations on Rockdodger", "VoR");
507 NULLERROR(surf_screen);
509 // Set the heat color from the range 0 (cold) to 300 (blue-white)
510 for(i = 0; i<W*3; i++) {
511 heatcolor[i] = SDL_MapRGB(
513 (i<W)?(i*M/W):(M),(i<W)?0:(i<2*W)?((i-W)*M/W):M,(i<2*W)?0:((i-W)*M/W) // Got that?
518 NULLERROR(temp = IMG_Load(add_path("banners/variations.png")));
519 NULLERROR(surf_b_variations = SDL_DisplayFormat(temp));
521 NULLERROR(temp = IMG_Load(add_path("banners/on.png")));
522 NULLERROR(surf_b_on = SDL_DisplayFormat(temp));
524 NULLERROR(temp = IMG_Load(add_path("banners/rockdodger.png")));
525 NULLERROR(surf_b_rockdodger = SDL_DisplayFormat(temp));
527 NULLERROR(temp = IMG_Load(add_path("banners/game.png")));
528 NULLERROR(surf_b_game = SDL_DisplayFormat(temp));
530 NULLERROR(temp = IMG_Load(add_path("banners/over.png")));
531 NULLERROR(surf_b_over = SDL_DisplayFormat(temp));
533 surf_font_big = IMG_Load(add_path(BIG_FONT_FILE));
534 g_font = SFont_InitFont(surf_font_big);
536 // Load the spaceship graphic.
537 NULLERROR(temp = IMG_Load(add_path("sprites/ship.png")));
538 NULLERROR(surf_ship = SDL_DisplayFormat(temp));
539 get_shape(surf_ship, &shipshape);
541 // Load the life indicator (small ship) graphic.
542 NULLERROR(temp = IMG_Load(add_path("indicators/life.png")));
543 NULLERROR(surf_life = SDL_DisplayFormat(temp));
548 // Load all our lovely rocks
549 for(i = 0; i<NROCKS; i++) {
550 snprintf(a,MAX_PATH_LEN,add_path("sprites/rock%02d.png"),i);
551 NULLERROR(temp = IMG_Load(a));
552 NULLERROR(surf_rock[i] = SDL_DisplayFormat(temp));
553 get_shape(surf_rock[i], &rock_shapes[i]);
556 // Remove the mouse cursor
558 SDL_ShowCursor(SDL_DISABLE);
570 float fadegame,fadeover;
579 // Draw a fully black background
580 SDL_FillRect(surf_screen,NULL,0);
582 // Draw the background dots
583 drawdots(surf_screen);
586 if(!gameover && state == GAMEPLAY ) {
587 src.w = surf_ship->w;
588 src.h = surf_ship->h;
593 SDL_BlitSurface(surf_ship,&src,surf_screen,&dest);
596 // Draw all the rocks, in all states
597 for(i = 0; i<MAXROCKS; i++) {
600 src.w = rock[i].image->w;
601 src.h = rock[i].image->h;
604 dest.x = (int) rock[i].x;
605 dest.y = (int) rock[i].y;
608 SDL_BlitSurface(rock[i].image,&src,surf_screen,&dest);
613 // If it's game over, show the game over graphic in the dead centre
616 if(fadetimer<3.0/faderate) {
617 fadegame = fadetimer/(3.0/faderate);
622 if(fadetimer<3.0/faderate) {
624 } else if(fadetimer<6.0/faderate) {
625 fadeover = ((3.0/faderate)-fadetimer)/(6.0/faderate);
630 src.w = surf_b_game->w;
631 src.h = surf_b_game->h;
634 dest.x = (XSIZE-src.w)/2;
635 dest.y = (YSIZE-src.h)/2-40;
636 SDL_SetAlpha(surf_b_game, SDL_SRCALPHA, (int)(fadegame*(200 + 55*cos(fadetimer += movementrate/1.0))));
637 SDL_BlitSurface(surf_b_game,&src,surf_screen,&dest);
639 src.w = surf_b_over->w;
640 src.h = surf_b_over->h;
643 dest.x = (XSIZE-src.w)/2;
644 dest.y = (YSIZE-src.h)/2 + 40;
645 SDL_SetAlpha(surf_b_over, SDL_SRCALPHA, (int)(fadeover*(200 + 55*sin(fadetimer))));
646 SDL_BlitSurface(surf_b_over,&src,surf_screen,&dest);
651 src.w = surf_b_variations->w;
652 src.h = surf_b_variations->h;
655 dest.x = (XSIZE-src.w)/2 + cos(fadetimer/6.5)*10;
656 dest.y = (YSIZE/2-src.h)/2 + sin(fadetimer/5.0)*10;
657 SDL_SetAlpha(surf_b_variations, SDL_SRCALPHA, (int)(200 + 55*sin(fadetimer += movementrate/2.0)));
658 SDL_BlitSurface(surf_b_variations,&src,surf_screen,&dest);
660 src.w = surf_b_on->w;
661 src.h = surf_b_on->h;
664 dest.x = (XSIZE-src.w)/2 + cos((fadetimer + 1.0)/6.5)*10;
665 dest.y = (YSIZE/2-src.h)/2 + surf_b_variations->h + 20 + sin((fadetimer + 1.0)/5.0)*10;
666 SDL_SetAlpha(surf_b_on, SDL_SRCALPHA, (int)(200 + 55*sin(fadetimer-1.0)));
667 SDL_BlitSurface(surf_b_on,&src,surf_screen,&dest);
669 src.w = surf_b_rockdodger->w;
670 src.h = surf_b_rockdodger->h;
673 dest.x = (XSIZE-src.w)/2 + cos((fadetimer + 2.0)/6.5)*10;
674 dest.y = (YSIZE/2-src.h)/2 + surf_b_variations->h + surf_b_on->h + 40 + sin((fadetimer + 2.0)/5)*10;
675 SDL_SetAlpha(surf_b_rockdodger, SDL_SRCALPHA, (int)(200 + 55*sin(fadetimer-2.0)));
676 SDL_BlitSurface(surf_b_rockdodger,&src,surf_screen,&dest);
678 text = "Version " VERSION;
679 x = (XSIZE-SFont_TextWidth(g_font,text))/2 + sin(fadetimer/4.5)*10;
680 SFont_Write(surf_screen,g_font,x,YSIZE-50 + sin(fadetimer/2)*5,text);
682 text = sequence[(int)(fadetimer/40)%NSEQUENCE];
683 //text = "Press SPACE to start!";
684 x = (XSIZE-SFont_TextWidth(g_font,text))/2 + cos(fadetimer/4.5)*10;
685 SFont_Write(surf_screen,g_font,x,YSIZE-100 + cos(fadetimer/3)*5,text);
688 case HIGH_SCORE_ENTRY:
690 if(!process_score_input()) { // done inputting name
692 // Change state to briefly show high scores page
693 state = HIGH_SCORE_DISPLAY;
696 // Write the high score table to the file
697 write_high_score_table();
699 // Play the title page tune
703 case HIGH_SCORE_DISPLAY:
704 // Display de list o high scores mon.
705 display_scores(surf_screen, 150,50);
709 ; // no action necessary
712 if(!gameover && state == GAMEPLAY) {
713 for(i=0; i<MAXROCKS; i++) {
715 if(collide(shipx-rock[i].x, shipy-rock[i].y, rock[i].shape, &shipshape))
721 // Draw all the little ships
722 if(state == GAMEPLAY || state == DEAD_PAUSE || state == GAME_OVER)
723 for(i = 0; i<nships-1; i++) {
724 src.w = surf_life->w;
725 src.h = surf_life->h;
728 dest.x = (i + 1)*(src.w + 10);
730 SDL_BlitSurface(surf_life,&src,surf_screen,&dest);
736 n = SDL_GetTicks()-initticks;
738 ticks_since_last = n-score;
742 ticks_since_last = SDL_GetTicks()-last_ticks;
743 last_ticks = SDL_GetTicks();
744 if(ticks_since_last>200 || ticks_since_last<0) {
748 movementrate = ticks_since_last/50.0;
749 if(state == GAMEPLAY) {
750 score += ticks_since_last;
754 // Update the surface
755 SDL_Flip(surf_screen);
769 // Count down the game loop timer, and change state when it gets to zero or less;
771 if((state_timeout -= movementrate*3) < 0) {
774 // Create a new ship and start all over again
780 state = HIGH_SCORE_ENTRY;
781 state_timeout = 5.0e6;
782 if(new_high_score(score)) {
784 SDL_EnableUNICODE(1);
785 while(SDL_PollEvent(&e))
788 state = HIGH_SCORE_DISPLAY;
792 case HIGH_SCORE_DISPLAY:
794 state_timeout = 500.0;
796 case HIGH_SCORE_ENTRY:
797 // state = TITLE_PAGE;
799 // state_timeout = 100.0;
802 state = HIGH_SCORE_DISPLAY;
803 state_timeout = 200.0;
806 ; // no action necessary
809 if(state == DEAD_PAUSE) {
813 if(state_timeout < DEAD_PAUSE_LENGTH - 20.0) {
814 blast_radius = BLAST_RADIUS * 1.3;
817 blast_radius = BLAST_RADIUS * (DEAD_PAUSE_LENGTH - state_timeout) / 20.0;
821 if(shipx < 60) shipx = 60;
822 for(i = 0; i<MAXROCKS; i++ ) {
824 if(rock[i].x <= 0) continue;
826 // This makes it so your explosion from dying magically doesn't leave
827 // any rocks that aren't moving much on the x axis. After the first
828 // 20 tics, only rocks that are barely moving will be pushed.
829 if(fixonly && (!rock[i].dead || rock[i].dx < -4 || rock[i].dx > 3)) {
833 dx = rock[i].x - shipx;
834 dy = rock[i].y - shipy;
836 n = sqrt(dx*dx + dy*dy);
837 if(n < blast_radius) {
839 rock[i].dx += rockrate*(dx+30)/n;
840 rock[i].dy += rockrate*dy/n;
847 if(--countdown <= 0 && (rnd()*100.0<(rockrate += 0.025))) {
850 if(rockptr-rock >= MAXROCKS) {
853 if(!rockptr->active) {
854 rockptr->x = (float)XSIZE;
855 rockptr->dx = -(rockspeed)*(1 + rnd());
856 rockptr->dy = rnd()-0.5;
857 rockptr->type_number = random() % NROCKS;
858 rockptr->image = surf_rock[rockptr->type_number];// [random()%NROCKS];
859 rockptr->shape = &rock_shapes[rockptr->type_number];
861 rockptr->y = rnd()*(YSIZE + rockptr->image->h);
863 if(movementrate>0.1) {
864 countdown = (int)(ROCKRATE/movementrate);
872 shipdx *= pow((double)0.9,(double)movementrate);
873 shipdy *= pow((double)0.9,(double)movementrate);
874 // if(abs(shipdx)<0.00001) shipdx = 0;
875 // if(abs(shipdy)<0.00001) shipdy = 0;
879 shipx += shipdx*movementrate;
880 shipy += shipdy*movementrate;
883 yscroll = shipy - (YSIZE / 2);
884 yscroll += shipdy * 25;
886 yscroll = ((scrollvel * (12 - movementrate)) + (yscroll * movementrate)) / 12;
888 yscroll = yscroll*movementrate;
891 // Move all the rocks
892 for(i = 0; i < MAXROCKS; i++) {
894 rock[i].x += rock[i].dx*movementrate;
895 rock[i].y += rock[i].dy*movementrate + yscroll;
896 if(rock[i].y > YSIZE || rock[i].y < -rock[i].image->h) {
902 rock[i].y = (YSIZE - rock[i].image->h) - rock[i].y;
903 rock[i].y += (rock[i].dy*movementrate + yscroll) * 1.01;
906 if(rock[i].x < -rock[i].image->w || rock[i].x > XSIZE) {
915 if(shipx<0 || shipx>XSIZE-surf_ship->w) {
916 // BOUNCE from left and right wall
917 shipx -= shipdx*movementrate;
922 if(shipy<0 || shipy>YSIZE-surf_ship->h) {
923 // BOUNCE from top and bottom wall
929 if(draw() && state == GAMEPLAY) {
930 // Play the explosion sound
932 makebangdots(shipx,shipy,shipdx,shipdy,surf_ship,30);
936 state_timeout = 200.0;
938 faderate = movementrate;
942 state_timeout = DEAD_PAUSE_LENGTH;
949 keystate = SDL_GetKeyState(NULL);
951 if(state != HIGH_SCORE_ENTRY && (keystate[SDLK_q] || keystate[SDLK_ESCAPE])) {
955 if(keystate[SDLK_SPACE] && (state == HIGH_SCORE_DISPLAY || state == TITLE_PAGE)) {
957 for(i = 0; i<MAXROCKS; i++ ) {
981 keystate = SDL_GetKeyState(NULL);
984 if(state == GAMEPLAY) {
988 if(keystate[SDLK_UP] | keystate[SDLK_c]) { shipdy -= 1.5*movementrate; maneuver |= 1<<3;}
989 if(keystate[SDLK_DOWN] | keystate[SDLK_t]) { shipdy += 1.5*movementrate; maneuver |= 1<<1;}
990 if(keystate[SDLK_LEFT] | keystate[SDLK_h]) { shipdx -= 1.5*movementrate; maneuver |= 1<<2;}
991 if(keystate[SDLK_RIGHT] | keystate[SDLK_n]) { shipdx += 1.5*movementrate; maneuver |= 1;}
992 if(keystate[SDLK_3]) { SDL_SaveBMP(surf_screen, "snapshot.bmp"); }
995 if(keystate[SDLK_p] | keystate[SDLK_s]) {
1009 } else if(state == GAME_OVER) {
1010 if(keystate[SDLK_SPACE]) {
1018 main(int argc, char **argv) {
1019 int i, x, fullscreen;
1027 while ((x = getopt(argc,argv,"efhmps")) >= 0) {
1032 case 'f': // fullscreen
1036 printf("Variations on RockDodger\n"
1037 " -e big tail [E]ngine\n"
1038 " -f [F]ull screen\n"
1039 " -h this [H]elp message\n"
1040 " -m enable [M]usic\n"
1041 " -p original [P]hysics (friction)\n"
1042 " -s [S]ilent (no sound)\n");
1047 case 'p': // physics
1057 if(init(fullscreen)) {
1058 printf ("ta: '%s'\n",initerror);
1062 for(i = 0; i<MAXROCKS; i++) {
1068 initticks = SDL_GetTicks();