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
31 #include <SDL/SDL_image.h>
40 #define CONDERROR(a) if((a)) {initerror = strdup(SDL_GetError());return 1;}
41 #define NULLERROR(a) CONDERROR((a) == NULL)
43 // ************************************* STRUCTS
45 // Array of black pixel coordinates. This is scanned
46 // every frame to see if it's still black, and as
47 // soon as it isn't we BLOW UP
50 int dead; // has been blown out of the way
51 // to make room for a new ship appearing.
55 struct black_point_struct {
59 // Bang dots have the same colour as shield dots.
60 // Bang dots get darker as they age.
61 // Some are coloured the same as the ex-ship.
63 Uint16 c; // when zero, use heatcolor[bangdotlife]
64 float life; // When reduced to 0, set active = 0
66 float decay;// Amount by which to reduce life each time dot is drawn
69 // Engine dots stream out the back of the ship, getting darker as they go.
72 // The life of an engine dot
73 // is a number starting at between 0 and 50 and counting backward.
74 float life; // When reduced to 0, set active = 0
77 // Space dots are harmless background items
78 // All are active. When one falls off the edge, another is created at the start.
83 // ************************************* VARS
84 // SDL_Surface global variables
86 *surf_screen, // Screen
87 *surf_b_variations, // "variations" banner
88 *surf_b_on, // "on" banner
89 *surf_b_rockdodger, // "rockdodger" banner
90 *surf_b_game, // Title element "game"
91 *surf_b_over, // Title element "over"
92 *surf_ship, // Spaceship element
93 *surf_life, // Indicator of number of ships remaining
94 *surf_rock[NROCKS], // THE ROCKS
95 *surf_deadrock[NROCKS], // THE DEAD ROCKS
96 *surf_font_big; // The big font
100 // Structure global variables
101 struct enginedots edot[MAXENGINEDOTS], *dotptr = edot;
102 struct rock_struct rock[MAXROCKS], *rockptr = rock;
103 struct black_point_struct black_point[MAXBLACKPOINTS], *blackptr = black_point;
104 struct bangdots bdot[MAXBANGDOTS], *bdotptr = bdot;
105 struct spacedot sdot[MAXSPACEDOTS];
107 // Other global variables
109 char *initerror = "";
111 float xship,yship = 240.0; // X position, 0..XSIZE
112 float xvel,yvel; // Change in X position per tick.
113 float rockrate,rockspeed;
118 int nships,score,initticks,ticks_since_last, last_ticks;
122 int sound_flag = 1, music_flag = 0;
123 int tail_plume = 0; // display big engine at the back?
124 int friction = 0; // should there be friction?
125 float fadetimer = 0, faderate;
127 int pausedown = 0, paused = 0;
129 // bangdot start (bd1) and end (bd2) position:
130 int bd1 = 0, bd2 = 0;
141 enum states state = TITLE_PAGE;
142 float state_timeout = 600.0;
146 "Press SPACE to start",
147 "http://qualdan.com/vor/"
150 int bangdotlife, nbangdots;
151 Uint16 heatcolor[W*3];
155 extern int optind, opterr, optopt;
157 float dist_sq(float x1, float y1, float x2, float y2)
159 return (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
162 // ************************************* FUNCS
166 return (float)random()/(float)RAND_MAX;
172 for(i = 0; i<MAXENGINEDOTS; i++) {
180 for(i = 0; i<MAXSPACEDOTS; i++) {
183 sdot[i].x = rnd()*(XSIZE-5);
184 sdot[i].y = rnd()*(YSIZE-5);
190 intensity = (int)(r*180 + 70);
191 sdot[i].color = SDL_MapRGB(surf_screen->format,intensity,intensity,intensity);
197 makebangdots(int xbang, int ybang, int xvel, int yvel, SDL_Surface *s, int power) {
199 // TODO - stop generating dots after a certain amount of time has passed, to cope with slower CPUs.
200 // TODO - generate and display dots in a circular buffer
207 begin_generate = SDL_GetTicks();
210 rawpixel = (Uint16 *) s->pixels;
212 //for(n = 0; n <= power/2; n++) {
216 for(x = 0; x<s->w; x++) {
217 for(y = 0; y<s->h; y++) {
218 c = rawpixel[s->pitch/2*y + x];
219 if(c && c != SDL_MapRGB(s->format,0,255,0)) {
221 theta = rnd()*M_PI*2;
225 bdot[bd2].dx = (power/50.0)*45.0*cos(theta)*r + xvel;
226 bdot[bd2].dy = (power/50.0)*45.0*sin(theta)*r + yvel;
227 bdot[bd2].x = x + xbang;
228 bdot[bd2].y = y + ybang;
230 // Replace the last few bang dots with the pixels from the exploding object
231 bdot[bd2].c = (endcount>0)?c:0;
232 bdot[bd2].life = 100;
233 bdot[bd2].decay = rnd()*3 + 1;
234 bdot[bd2].active = 1;
239 // If the circular buffer is filled, who cares? They've had their chance.
240 //if(bd2 == bd1-1) goto exitloop;
246 if(SDL_GetTicks() - begin_generate > 7) endcount++;
249 SDL_UnlockSurface(s);
254 draw_bang_dots(SDL_Surface *s) {
258 rawpixel = (Uint16 *) s->pixels;
262 for(i = bd1; (bd1 <= bd2)?(i<bd2):(i >= bd1 && i < bd2); last_i = ++i) {
266 if(bdot[i].x <= 0 || bdot[i].x >= XSIZE || bdot[i].y <= 0 || bdot[i].y >= YSIZE) {
267 // If the dot has drifted outside the perimeter, kill it
275 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)];
276 bdot[i].life -= bdot[i].decay;
277 bdot[i].x += bdot[i].dx*movementrate;
278 bdot[i].y += bdot[i].dy*movementrate + yscroll;
298 draw_space_dots(SDL_Surface *s) {
301 rawpixel = (Uint16 *) s->pixels;
303 for(i = 0; i<MAXSPACEDOTS; i++) {
307 rawpixel[(int)(s->pitch/2*(int)sdot[i].y) + (int)(sdot[i].x)] = sdot[i].color;
308 sdot[i].x += sdot[i].dx*movementrate;
309 sdot[i].y += yscroll;
310 if(sdot[i].y > YSIZE) {
312 } else if(sdot[i].y < 0) {
322 draw_engine_dots(SDL_Surface *s) {
325 rawpixel = (Uint16 *) s->pixels;
327 for(i = 0; i<MAXENGINEDOTS; i++) {
329 edot[i].x += edot[i].dx*movementrate;
330 edot[i].y += edot[i].dy*movementrate + yscroll;
331 if((edot[i].life -= movementrate*3)<0 || edot[i].y<0 || edot[i].y>YSIZE) {
333 } else if(edot[i].x<0 || edot[i].x>XSIZE) {
337 heatindex = edot[i].life * 6;
338 //rawpixel[(int)(s->pitch/2*(int)(edot[i].y)) + (int)(edot[i].x)] = lifecolor[(int)(edot[i].life)];
339 rawpixel[(int)(s->pitch/2*(int)(edot[i].y)) + (int)(edot[i].x)] = heatindex>3*W ? heatcolor[3*W-1] : heatcolor[heatindex];
346 create_engine_dots(int newdots) {
348 double theta,r,dx,dy;
350 if(!tail_plume) return;
352 if(state == GAMEPLAY) {
353 for(i = 0; i<newdots*movementrate; i++) {
354 if(dotptr->active == 0) {
355 theta = rnd()*M_PI*2;
361 dotptr->x = xship + surf_ship->w/2-14;
362 dotptr->y = yship + surf_ship->h/2 + (rnd()-0.5)*5-1;
363 dotptr->dx = 10*(dx-1.5) + xvel;
364 dotptr->dy = 1*dy + yvel;
365 dotptr->life = 45 + rnd(1)*5;
368 if(dotptr-edot >= MAXENGINEDOTS) {
377 create_engine_dots2(int newdots, int m) {
379 double theta, theta2, dx, dy, adx, ady;
381 // Don't create fresh engine dots when
382 // the game is not being played and a demo is not beng shown
383 if(state != GAMEPLAY && state != DEMO) return;
385 for(i = 0; i<newdots; i++) {
386 if(dotptr->active == 0) {
387 theta = rnd()*M_PI*2;
388 theta2 = rnd()*M_PI*2;
390 dx = cos(theta) * fabs(cos(theta2));
391 dy = sin(theta) * fabs(cos(theta2));
397 dotptr->x = xship + surf_ship->w/2 + (rnd()-0.5)*3;
398 dotptr->y = yship + surf_ship->h/2 + (rnd()-0.5)*3;
403 dotptr->dx = -20*adx + xvel;
404 dotptr->dy = 2*dy + yvel;
405 dotptr->life = 60 * adx;
408 dotptr->dx = 2*dx + xvel;
409 dotptr->dy = -20*ady + yvel;
410 dotptr->life = 60 * ady;
414 dotptr->dx = 20*adx + xvel;
415 dotptr->dy = 2*dy + yvel;
416 dotptr->life = 60 * adx;
419 dotptr->dx = 2*dx + xvel;
420 dotptr->dy = 20*ady + yvel;
421 dotptr->life = 60 * ady;
425 if(dotptr-edot >= MAXENGINEDOTS) {
433 drawdots(SDL_Surface *s) {
437 // Draw the background stars aka space dots
440 // Draw the score when playing the game or whn the game is freshly over
441 if(1 || state == GAMEPLAY || state == DEAD_PAUSE || state == GAME_OVER ) {
442 SDL_UnlockSurface(s);
444 snprintscore_line(topline, 50, score);
445 SFont_Write(s,g_font,XSIZE-250,0,topline);
450 // Draw all the engine dots
453 // Create more engine dots comin out da back
454 if(!gameover) create_engine_dots(200);
456 // Create engine dots out the side we're moving from
457 for(m = 0; m<4; m++) {
458 if(maneuver & 1<<m) { // 'maneuver' is a bit field
459 create_engine_dots2(80,m);
463 // Draw all outstanding bang dots
464 //if(bangdotlife-- > 0)
467 SDL_UnlockSurface(s);
471 init(int fullscreen) {
478 // Where are our data files?
479 if(!find_files()) exit(1);
480 read_high_score_table();
483 // Initialize SDL with audio and video
484 if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0) {
486 printf ("Can't open sound, starting without it\n");
490 atexit(SDL_CloseAudio);
491 sound_flag = init_sound();
494 // Initialize with video only
495 CONDERROR(SDL_Init(SDL_INIT_VIDEO) != 0);
501 // Attempt to get the required video size
502 flag = SDL_DOUBLEBUF | SDL_HWSURFACE;
503 if(fullscreen) flag |= SDL_FULLSCREEN;
504 surf_screen = SDL_SetVideoMode(XSIZE,YSIZE,16,flag);
506 // Set the title bar text
507 SDL_WM_SetCaption("Variations on Rockdodger", "VoR");
509 NULLERROR(surf_screen);
511 // Set the heat color from the range 0 (cold) to 300 (blue-white)
512 for(i = 0; i<W*3; i++) {
513 heatcolor[i] = SDL_MapRGB(
515 (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?
520 NULLERROR(temp = IMG_Load(load_file("banners/variations.png")));
521 NULLERROR(surf_b_variations = SDL_DisplayFormat(temp));
523 NULLERROR(temp = IMG_Load(load_file("banners/on.png")));
524 NULLERROR(surf_b_on = SDL_DisplayFormat(temp));
526 NULLERROR(temp = IMG_Load(load_file("banners/rockdodger.png")));
527 NULLERROR(surf_b_rockdodger = SDL_DisplayFormat(temp));
529 NULLERROR(temp = IMG_Load(load_file("banners/game.png")));
530 NULLERROR(surf_b_game = SDL_DisplayFormat(temp));
532 NULLERROR(temp = IMG_Load(load_file("banners/over.png")));
533 NULLERROR(surf_b_over = SDL_DisplayFormat(temp));
535 surf_font_big = IMG_Load(load_file(BIG_FONT_FILE));
536 g_font = SFont_InitFont(surf_font_big);
538 // Load the spaceship graphic.
539 NULLERROR(temp = IMG_Load(load_file("sprites/ship.png")));
540 NULLERROR(surf_ship = SDL_DisplayFormat(temp));
542 // Load the life indicator (small ship) graphic.
543 NULLERROR(temp = IMG_Load(load_file("indicators/life.png")));
544 NULLERROR(surf_life = SDL_DisplayFormat(temp));
546 // Create the array of black points;
547 SDL_LockSurface(surf_ship);
548 raw_pixels = (Uint16 *) surf_ship->pixels;
549 for(i = 0; i<surf_ship->w; i++) {
550 for(j = 0; j<surf_ship->h; j++) {
551 if(raw_pixels[j*(surf_ship->pitch)/2 + i] == 0) {
559 SDL_UnlockSurface(surf_ship);
564 // Load all our lovely rocks
565 for(i = 0; i<NROCKS; i++) {
568 sprintf(a,load_file("sprites/rock%d.png"),i);
569 NULLERROR(temp = IMG_Load(a));
570 NULLERROR(surf_rock[i] = SDL_DisplayFormat(temp));
572 sprintf(a,load_file("sprites/deadrock%d.png"),i);
573 NULLERROR(temp = IMG_Load(a));
574 NULLERROR(surf_deadrock[i] = SDL_DisplayFormat(temp));
577 // Remove the mouse cursor
579 SDL_ShowCursor(SDL_DISABLE);
589 struct black_point_struct *p;
593 float fadegame,fadeover;
602 // Draw a fully black background
603 SDL_FillRect(surf_screen,NULL,0);
605 // Draw the background dots
606 drawdots(surf_screen);
609 if(!gameover && (state == GAMEPLAY || state == DEMO) ) {
610 src.w = surf_ship->w;
611 src.h = surf_ship->h;
616 SDL_BlitSurface(surf_ship,&src,surf_screen,&dest);
619 // Draw all the rocks, in all states
620 for(i = 0; i<MAXROCKS; i++) {
623 src.w = rock[i].image->w;
624 src.h = rock[i].image->h;
627 dest.x = (int) rock[i].x;
628 dest.y = (int) rock[i].y;
631 SDL_BlitSurface(rock[i].image,&src,surf_screen,&dest);
636 // If it's game over, show the game over graphic in the dead centre
639 if(fadetimer<3.0/faderate) {
640 fadegame = fadetimer/(3.0/faderate);
645 if(fadetimer<3.0/faderate) {
647 } else if(fadetimer<6.0/faderate) {
648 fadeover = ((3.0/faderate)-fadetimer)/(6.0/faderate);
653 src.w = surf_b_game->w;
654 src.h = surf_b_game->h;
657 dest.x = (XSIZE-src.w)/2;
658 dest.y = (YSIZE-src.h)/2-40;
659 SDL_SetAlpha(surf_b_game, SDL_SRCALPHA, (int)(fadegame*(200 + 55*cos(fadetimer += movementrate/1.0))));
660 SDL_BlitSurface(surf_b_game,&src,surf_screen,&dest);
662 src.w = surf_b_over->w;
663 src.h = surf_b_over->h;
666 dest.x = (XSIZE-src.w)/2;
667 dest.y = (YSIZE-src.h)/2 + 40;
668 SDL_SetAlpha(surf_b_over, SDL_SRCALPHA, (int)(fadeover*(200 + 55*sin(fadetimer))));
669 SDL_BlitSurface(surf_b_over,&src,surf_screen,&dest);
674 src.w = surf_b_variations->w;
675 src.h = surf_b_variations->h;
678 dest.x = (XSIZE-src.w)/2 + cos(fadetimer/6.5)*10;
679 dest.y = (YSIZE/2-src.h)/2 + sin(fadetimer/5.0)*10;
680 SDL_SetAlpha(surf_b_variations, SDL_SRCALPHA, (int)(200 + 55*sin(fadetimer += movementrate/2.0)));
681 SDL_BlitSurface(surf_b_variations,&src,surf_screen,&dest);
683 src.w = surf_b_on->w;
684 src.h = surf_b_on->h;
687 dest.x = (XSIZE-src.w)/2 + cos((fadetimer + 1.0)/6.5)*10;
688 dest.y = (YSIZE/2-src.h)/2 + surf_b_variations->h + 20 + sin((fadetimer + 1.0)/5.0)*10;
689 SDL_SetAlpha(surf_b_on, SDL_SRCALPHA, (int)(200 + 55*sin(fadetimer-1.0)));
690 SDL_BlitSurface(surf_b_on,&src,surf_screen,&dest);
692 src.w = surf_b_rockdodger->w;
693 src.h = surf_b_rockdodger->h;
696 dest.x = (XSIZE-src.w)/2 + cos((fadetimer + 2.0)/6.5)*10;
697 dest.y = (YSIZE/2-src.h)/2 + surf_b_variations->h + surf_b_on->h + 40 + sin((fadetimer + 2.0)/5)*10;
698 SDL_SetAlpha(surf_b_rockdodger, SDL_SRCALPHA, (int)(200 + 55*sin(fadetimer-2.0)));
699 SDL_BlitSurface(surf_b_rockdodger,&src,surf_screen,&dest);
701 text = "Version " VERSION;
702 x = (XSIZE-SFont_TextWidth(g_font,text))/2 + sin(fadetimer/4.5)*10;
703 SFont_Write(surf_screen,g_font,x,YSIZE-50 + sin(fadetimer/2)*5,text);
705 text = sequence[(int)(fadetimer/40)%NSEQUENCE];
706 //text = "Press SPACE to start!";
707 x = (XSIZE-SFont_TextWidth(g_font,text))/2 + cos(fadetimer/4.5)*10;
708 SFont_Write(surf_screen,g_font,x,YSIZE-100 + cos(fadetimer/3)*5,text);
711 case HIGH_SCORE_ENTRY:
713 if(!process_score_input()) { // done inputting name
715 // Change state to briefly show high scores page
716 state = HIGH_SCORE_DISPLAY;
719 // Write the high score table to the file
720 write_high_score_table();
722 // Play the title page tune
726 case HIGH_SCORE_DISPLAY:
727 // Display de list o high scores mon.
728 display_scores(surf_screen, 150,50);
732 if(!gameover && state == GAMEPLAY) {
733 SDL_LockSurface(surf_screen);
734 raw_pixels = (Uint16 *) surf_screen->pixels;
735 // Check that the black points on the ship are
736 // still black, and not covered up by rocks.
737 for(p = black_point; p<blackptr; p++) {
738 offset = surf_screen->pitch/2 * (p->y + (int)yship) + p->x + (int)xship;
739 if(raw_pixels[offset]) {
744 SDL_UnlockSurface(surf_screen);
747 // Draw all the little ships
748 if(state == GAMEPLAY || state == DEAD_PAUSE || state == GAME_OVER)
749 for(i = 0; i<nships-1; i++) {
750 src.w = surf_life->w;
751 src.h = surf_life->h;
754 dest.x = (i + 1)*(src.w + 10);
756 SDL_BlitSurface(surf_life,&src,surf_screen,&dest);
762 n = SDL_GetTicks()-initticks;
764 ticks_since_last = n-score;
768 ticks_since_last = SDL_GetTicks()-last_ticks;
769 last_ticks = SDL_GetTicks();
770 if(ticks_since_last>200 || ticks_since_last<0) {
774 movementrate = ticks_since_last/50.0;
775 if(state == GAMEPLAY) {
776 score += ticks_since_last;
780 // Update the surface
781 SDL_Flip(surf_screen);
795 // Count down the game loop timer, and change state when it gets to zero or less;
797 if((state_timeout -= movementrate*3) < 0) {
800 // Create a new ship and start all over again
806 state = HIGH_SCORE_ENTRY;
807 state_timeout = 5.0e6;
808 if(new_high_score(score)) {
810 SDL_EnableUNICODE(1);
811 while(SDL_PollEvent(&e))
814 state = HIGH_SCORE_DISPLAY;
818 case HIGH_SCORE_DISPLAY:
820 state_timeout = 500.0;
822 case HIGH_SCORE_ENTRY:
823 // state = TITLE_PAGE;
825 // state_timeout = 100.0;
828 state = HIGH_SCORE_DISPLAY;
829 state_timeout = 200.0;
833 if(state == DEAD_PAUSE) {
834 float blast_radius = BLAST_RADIUS * state_timeout / 20.0;
835 if(xship < 60) xship = 60;
836 for(i = 0; i<MAXROCKS; i++ ) {
838 if(rock[i].x <= 0) continue;
839 dx = rock[i].x - xship;
840 dy = rock[i].y - yship;
841 n = sqrt(dx*dx + dy*dy);
842 if(n < blast_radius) {
844 rock[i].xvel += rockrate*(dx+30)/n;
845 rock[i].yvel += rockrate*dy/n;
852 if(--countdown <= 0 && (rnd()*100.0<(rockrate += 0.025))) {
855 if(rockptr-rock >= MAXROCKS) {
858 if(!rockptr->active) {
859 rockptr->x = (float)XSIZE;
860 rockptr->xvel = -(rockspeed)*(1 + rnd());
861 rockptr->yvel = rnd()-0.5;
862 rockptr->type_number = random() % NROCKS;
863 rockptr->image = surf_rock[rockptr->type_number];// [random()%NROCKS];
865 rockptr->y = rnd()*(YSIZE + rockptr->image->h);
867 if(movementrate>0.1) {
868 countdown = (int)(ROCKRATE/movementrate);
876 xvel *= pow((double)0.9,(double)movementrate);
877 yvel *= pow((double)0.9,(double)movementrate);
878 // if(abs(xvel)<0.00001) xvel = 0;
879 // if(abs(yvel)<0.00001) yvel = 0;
883 xship += xvel*movementrate;
884 yship += yvel*movementrate;
887 yscroll = yship - (YSIZE / 2);
888 yscroll += yvel * 25;
890 yscroll = ((scrollvel * (12 - movementrate)) + (yscroll * movementrate)) / 12;
892 yscroll = yscroll*movementrate;
895 // Move all the rocks
896 for(i = 0; i < MAXROCKS; i++) {
898 rock[i].x += rock[i].xvel*movementrate;
899 rock[i].y += rock[i].yvel*movementrate + yscroll;
900 if(rock[i].y > YSIZE || rock[i].y < -rock[i].image->h) {
906 rock[i].y = (YSIZE - rock[i].image->h) - rock[i].y;
907 rock[i].y += (rock[i].yvel*movementrate + yscroll) * 1.01;
910 if(rock[i].x < -rock[i].image->w || rock[i].x > XSIZE) {
919 if(xship<0 || xship>XSIZE-surf_ship->w) {
920 // BOUNCE from left and right wall
921 xship -= xvel*movementrate;
926 if(yship<0 || yship>YSIZE-surf_ship->h) {
927 // BOUNCE from top and bottom wall
933 if(draw() && state == GAMEPLAY) {
934 // Play the explosion sound
936 makebangdots(xship,yship,xvel,yvel,surf_ship,30);
940 state_timeout = 200.0;
942 faderate = movementrate;
946 state_timeout = 20.0;
953 keystate = SDL_GetKeyState(NULL);
955 if(state != HIGH_SCORE_ENTRY && (keystate[SDLK_q] || keystate[SDLK_ESCAPE])) {
959 if(keystate[SDLK_SPACE] && (state == HIGH_SCORE_DISPLAY || state == TITLE_PAGE || state == DEMO)) {
961 for(i = 0; i<MAXROCKS; i++ ) {
986 keystate = SDL_GetKeyState(NULL);
989 if(state == GAMEPLAY) {
993 if(keystate[SDLK_UP] | keystate[SDLK_c]) { yvel -= 1.5*movementrate; maneuver |= 1<<3;}
994 if(keystate[SDLK_DOWN] | keystate[SDLK_t]) { yvel += 1.5*movementrate; maneuver |= 1<<1;}
995 if(keystate[SDLK_LEFT] | keystate[SDLK_h]) { xvel -= 1.5*movementrate; maneuver |= 1<<2;}
996 if(keystate[SDLK_RIGHT] | keystate[SDLK_n]) { xvel += 1.5*movementrate; maneuver |= 1;}
997 if(keystate[SDLK_3]) { SDL_SaveBMP(surf_screen, "snapshot.bmp"); }
1000 if(keystate[SDLK_p] | keystate[SDLK_s]) {
1005 src.w = surf_b_variations->w;
1006 src.h = surf_b_variations->h;
1009 dest.x = (XSIZE-src.w)/2;
1010 dest.y = (YSIZE-src.h)/2;
1011 SDL_BlitSurface(surf_b_variations,&src,surf_screen,&dest);
1012 // Update the surface
1013 SDL_Flip(surf_screen);
1026 } else if(state == GAME_OVER) {
1027 if(keystate[SDLK_SPACE]) {
1035 main(int argc, char **argv) {
1036 int i, x, fullscreen;
1044 while ((x = getopt(argc,argv,"efhmps")) >= 0) {
1049 case 'f': // fullscreen
1053 printf("Variations on RockDodger\n"
1054 " -e big tail [E]ngine\n"
1055 " -f [F]ull screen\n"
1056 " -h this [H]elp message\n"
1057 " -m enable [M]usic\n"
1058 " -p original [P]hysics (friction)\n"
1059 " -s [S]ilent (no sound)\n");
1064 case 'p': // physics
1074 if(init(fullscreen)) {
1075 printf ("ta: '%s'\n",initerror);
1079 for(i = 0; i<MAXROCKS; i++) {
1085 initticks = SDL_GetTicks();