debug-mode featuring backscrolling! Split up of st_setup.
authorTobias Gläßer <tobi.web@gmx.de>
Fri, 26 Dec 2003 23:26:00 +0000 (23:26 +0000)
committerTobias Gläßer <tobi.web@gmx.de>
Fri, 26 Dec 2003 23:26:00 +0000 (23:26 +0000)
SVN-Revision: 48

src/gameloop.c
src/globals.h
src/menu.c
src/setup.c
src/setup.h
src/supertux.c

index 2561d03..15df2cd 100644 (file)
@@ -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: */
 
index 482ae16..f26dde7 100644 (file)
@@ -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;
 
index 7f0711a..ef2a3d4 100644 (file)
@@ -233,7 +233,7 @@ int drawmenu(void)
                 use_fullscreen = 0;
               else
                 use_fullscreen = 1;
-              st_setup();
+              st_video_setup();
               menu_change = YES;
             }
         }
index d7626d5..abca8ff 100644 (file)
@@ -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);
 
 
index 3174d60..e999b2a 100644 (file)
   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[]);
index 8616f1c..4d18534 100644 (file)
@@ -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();