From: Tobias Gläßer Date: Fri, 26 Dec 2003 23:26:00 +0000 (+0000) Subject: debug-mode featuring backscrolling! Split up of st_setup. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e7e01ac7e6765ff1906bfe1e811bd11f4c0f205e;p=supertux.git debug-mode featuring backscrolling! Split up of st_setup. SVN-Revision: 48 --- diff --git a/src/gameloop.c b/src/gameloop.c index 2561d036d..15df2cdd4 100644 --- a/src/gameloop.c +++ b/src/gameloop.c @@ -581,10 +581,18 @@ int game_action(void) /* Keep tux in bounds: */ - if (tux_x < 0) tux_x = 0; - else if (tux_x > 320 && scroll_x < ((level_width * 32) - 640)) + else if (tux_x < 160 && scroll_x > 0 && debug_mode == YES) + { + scroll_x = scroll_x - ( 160 - tux_x); + tux_x = 160; + + if(scroll_x < 0) + scroll_x = 0; + + } + else if (tux_x > 320 && scroll_x < ((level_width * 32) - 640)) { /* Scroll the screen in past center: */ diff --git a/src/globals.h b/src/globals.h index 482ae1667..f26dde707 100644 --- a/src/globals.h +++ b/src/globals.h @@ -19,7 +19,7 @@ SDL_Surface * screen; SDL_Surface * letters_black, * letters_gold, * letters_blue, * letters_red; -int use_joystick, use_fullscreen; +int use_joystick, use_fullscreen, debug_mode; int game_started; diff --git a/src/menu.c b/src/menu.c index 7f0711a59..ef2a3d4fa 100644 --- a/src/menu.c +++ b/src/menu.c @@ -233,7 +233,7 @@ int drawmenu(void) use_fullscreen = 0; else use_fullscreen = 1; - st_setup(); + st_video_setup(); menu_change = YES; } } diff --git a/src/setup.c b/src/setup.c index d7626d51f..abca8ff88 100644 --- a/src/setup.c +++ b/src/setup.c @@ -39,7 +39,7 @@ void usage(char * prog, int ret); /* --- SETUP --- */ -void st_setup(void) +void st_directory_setup(void) { /* Set SuperTux configuration and save directories */ @@ -65,12 +65,40 @@ void st_setup(void) /* Create them. In the case they exist it won't destroy anything. */ mkdir(st_dir, 0755); mkdir(st_save_dir, 0755); +} +void st_general_setup(void) +{ /* Seed random number generator: */ srand(SDL_GetTicks()); + + /* Load global images: */ + + letters_black = load_image(DATA_PREFIX "/images/status/letters-black.png", + USE_ALPHA); + + letters_gold = load_image(DATA_PREFIX "/images/status/letters-gold.png", + USE_ALPHA);/* + if (tux_x < 0) + tux_x = 0;*/ + + letters_blue = load_image(DATA_PREFIX "/images/status/letters-blue.png", + USE_ALPHA); + + letters_red = load_image(DATA_PREFIX "/images/status/letters-red.png", + USE_ALPHA); + /* Set icon image: */ + + seticon(); + +} + +void st_video_setup(void) +{ + /* Init SDL Video: */ if (SDL_Init(SDL_INIT_VIDEO) < 0) @@ -82,6 +110,44 @@ void st_setup(void) exit(1); } + /* Open display: */ + + if (use_fullscreen == YES) + { + screen = SDL_SetVideoMode(640, 480, 16, SDL_FULLSCREEN ) ; /* | SDL_HWSURFACE); */ + if (screen == NULL) + { + fprintf(stderr, + "\nWarning: I could not set up fullscreen video for " + "640x480 mode.\n" + "The Simple DirectMedia error that occured was:\n" + "%s\n\n", SDL_GetError()); + use_fullscreen = NO; + } + } + + if (use_fullscreen == NO) + { + screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE | SDL_DOUBLEBUF); + + if (screen == NULL) + { + fprintf(stderr, + "\nError: I could not set up video for 640x480 mode.\n" + "The Simple DirectMedia error that occured was:\n" + "%s\n\n", SDL_GetError()); + exit(1); + } + } + + /* Set window manager stuff: */ + + SDL_WM_SetCaption("Super Tux", "Super Tux"); + +} + +void st_joystick_setup(void) +{ /* Init Joystick: */ @@ -145,8 +211,10 @@ void st_setup(void) } #endif +} - +void st_audio_setup(void) +{ /* Init SDL Audio silently even if --disable-sound : */ @@ -198,61 +266,6 @@ void st_setup(void) } } - - /* Open display: */ - - if (use_fullscreen == YES) - { - screen = SDL_SetVideoMode(640, 480, 16, SDL_FULLSCREEN ) ; /* | SDL_HWSURFACE); */ - if (screen == NULL) - { - fprintf(stderr, - "\nWarning: I could not set up fullscreen video for " - "640x480 mode.\n" - "The Simple DirectMedia error that occured was:\n" - "%s\n\n", SDL_GetError()); - use_fullscreen = NO; - } - } - - if (use_fullscreen == NO) - { - screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE | SDL_DOUBLEBUF); - - if (screen == NULL) - { - fprintf(stderr, - "\nError: I could not set up video for 640x480 mode.\n" - "The Simple DirectMedia error that occured was:\n" - "%s\n\n", SDL_GetError()); - exit(1); - } - } - - - /* Load global images: */ - - letters_black = load_image(DATA_PREFIX "/images/status/letters-black.png", - USE_ALPHA); - - letters_gold = load_image(DATA_PREFIX "/images/status/letters-gold.png", - USE_ALPHA); - - letters_blue = load_image(DATA_PREFIX "/images/status/letters-blue.png", - USE_ALPHA); - - letters_red = load_image(DATA_PREFIX "/images/status/letters-red.png", - USE_ALPHA); - - - /* Set icon image: */ - - seticon(); - - - /* Set window manager stuff: */ - - SDL_WM_SetCaption("Super Tux", "Super Tux"); } @@ -324,6 +337,7 @@ void parseargs(int argc, char * argv[]) /* Set defaults: */ + debug_mode = NO; use_fullscreen = NO; #ifndef NOSOUND @@ -384,6 +398,12 @@ void parseargs(int argc, char * argv[]) #endif } + else if (strcmp(argv[i], "--debug-mode") == 0) + { + /* Enable the debug-mode */ + debug_mode = YES; + + } else if (strcmp(argv[i], "--help") == 0) { /* Show help: */ @@ -397,6 +417,8 @@ void parseargs(int argc, char * argv[]) printf(" --fullscreen - Run in fullscreen mode.\n\n"); + printf(" --debug-mode - Enables the debug-mode, which is useful for developers.\n\n"); + printf(" --help - Display a help message summarizing command-line\n options, license and game controls.\n\n"); printf(" --usage - Display a brief message summarizing command-line options.\n\n"); @@ -442,7 +464,7 @@ void usage(char * prog, int ret) /* Display the usage message: */ - fprintf(fi, "Usage: %s [--fullscreen] [--disable-sound] [--disable-music] | [--usage | --help | --version]\n", + fprintf(fi, "Usage: %s [--fullscreen] [--disable-sound] [--disable-music] [--debug-mode] | [--usage | --help | --version]\n", prog); diff --git a/src/setup.h b/src/setup.h index 3174d6007..e999b2a3e 100644 --- a/src/setup.h +++ b/src/setup.h @@ -10,7 +10,11 @@ April 11, 2000 - April 13, 2000 */ -void st_setup(void); +void st_directory_setup(void); +void st_general_setup(void); +void st_video_setup(void); +void st_audio_setup(void); +void st_joystick_setup(void); void st_shutdown(void); void st_abort(char * reason, char * details); void parseargs(int argc, char * argv[]); diff --git a/src/supertux.c b/src/supertux.c index 8616f1c60..4d18534aa 100644 --- a/src/supertux.c +++ b/src/supertux.c @@ -38,7 +38,11 @@ int main(int argc, char * argv[]) parseargs(argc, argv); - st_setup(); + st_directory_setup(); + st_audio_setup(); + st_video_setup(); + st_joystick_setup(); + st_general_setup(); done = intro();