Made display_text_file() to get the scroll speed as an argument. This way we can...
authorRicardo Cruz <rick2@aeiou.pt>
Wed, 28 Apr 2004 14:58:24 +0000 (14:58 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Wed, 28 Apr 2004 14:58:24 +0000 (14:58 +0000)
Anyway, you can easily change their speed in defines.h .

Also fixes a bug that was making the text to take while before starting to be displayed.

SVN-Revision: 811

src/defines.h
src/intro.cpp
src/text.cpp
src/text.h
src/title.cpp
src/worldmap.cpp

index c2c71a7..163f1bd 100644 (file)
@@ -89,6 +89,11 @@ enum DyingType {
 
 #define KICKING_TIME 200
 
+/* Scrolling text speed */
+
+#define SCROLL_SPEED_CREDITS 2.0
+#define SCROLL_SPEED_MESSAGE 1.0
+
 /* Debugging */
 
 #ifdef DEBUG
index a994f99..b8a6c4f 100644 (file)
@@ -33,6 +33,6 @@
 
 void draw_intro()
 {
-display_text_file("intro.txt", "/images/background/arctis2.jpg");
+display_text_file("intro.txt", "/images/background/arctis2.jpg", SCROLL_SPEED_MESSAGE);
 }
 
index ee0e7b8..4ef3cfe 100644 (file)
@@ -221,22 +221,23 @@ Text::erasecenteredtext(const  char * text, int y, Surface * ptexture, int updat
 
 /* --- SCROLL TEXT FUNCTION --- */
 
-#define MAX_VEL 10
-#define SPEED   1
-#define SCROLL  60
+#define MAX_VEL     10
+#define SPEED_INC   1.0
+#define SCROLL      60
 #define ITEMS_SPACE 4
 
-void display_text_file(const std::string& file, const std::string& surface)
+void display_text_file(const std::string& file, const std::string& surface, float scroll_speed)
 {
   Surface* sur = new Surface(datadir + surface, IGNORE_ALPHA);
-  display_text_file(file, sur);
+  display_text_file(file, sur, scroll_speed);
   delete sur;
 }
 
-void display_text_file(const std::string& file, Surface* surface)
+void display_text_file(const std::string& file, Surface* surface, float scroll_speed)
 {
   int done;
-  int scroll, speed;
+  int scroll;
+  float speed;
   int y;
   int length;
   FILE* fi;
@@ -265,7 +266,7 @@ void display_text_file(const std::string& file, Surface* surface)
 
 
   scroll = 0;
-  speed = 2;
+  speed = scroll_speed;
   done = 0;
 
   length = names.num_items;
@@ -283,10 +284,10 @@ void display_text_file(const std::string& file, Surface* surface)
             switch(event.key.keysym.sym)
               {
               case SDLK_UP:
-                speed -= SPEED;
+                speed -= SPEED_INC;
                 break;
               case SDLK_DOWN:
-                speed += SPEED;
+                speed += SPEED_INC;
                 break;
               case SDLK_SPACE:
               case SDLK_RETURN:
@@ -321,19 +322,19 @@ void display_text_file(const std::string& file, Surface* surface)
         switch(names.item[i][0])
           {
           case ' ':
-            white_small_text->drawf(names.item[i]+1, 0, 60+screen->h+y-scroll, A_HMIDDLE, A_TOP, 1);
+            white_small_text->drawf(names.item[i]+1, 0, screen->h+y-scroll, A_HMIDDLE, A_TOP, 1);
             y += white_small_text->h+ITEMS_SPACE;
             break;
           case '       ':
-            white_text->drawf(names.item[i]+1, 0, 60+screen->h+y-scroll, A_HMIDDLE, A_TOP, 1);
+            white_text->drawf(names.item[i]+1, 0, screen->h+y-scroll, A_HMIDDLE, A_TOP, 1);
             y += white_text->h+ITEMS_SPACE;
             break;
           case '-':
-            white_big_text->drawf(names.item[i]+1, 0, 60+screen->h+y-scroll, A_HMIDDLE, A_TOP, 3);
+            white_big_text->drawf(names.item[i]+1, 0, screen->h+y-scroll, A_HMIDDLE, A_TOP, 3);
             y += white_big_text->h+ITEMS_SPACE;
             break;
           default:
-            blue_text->drawf(names.item[i], 0, 60+screen->h+y-scroll, A_HMIDDLE, A_TOP, 1);
+            blue_text->drawf(names.item[i], 0, screen->h+y-scroll, A_HMIDDLE, A_TOP, 1);
             y += blue_text->h+ITEMS_SPACE;
             break;
           }
@@ -341,10 +342,10 @@ void display_text_file(const std::string& file, Surface* surface)
 
       flipscreen();
 
-      if(60+screen->h+y-scroll < 0 && 20+60+screen->h+y-scroll < 0)
+      if(screen->h+y-scroll < 0 && 20+screen->h+y-scroll < 0)
         done = 1;
 
-      scroll += speed;
+      scroll += (int)speed;
       if(scroll < 0)
         scroll = 0;
 
index d82a256..87066d7 100644 (file)
@@ -24,8 +24,8 @@
 #include <string>
 #include "texture.h"
 
-void display_text_file(const std::string& file, const std::string& surface);
-void display_text_file(const std::string& file, Surface* surface);
+void display_text_file(const std::string& file, const std::string& surface, float scroll_speed);
+void display_text_file(const std::string& file, Surface* surface, float scroll_speed);
 
 /* Kinds of texts. */
 enum {
index cb3a512..d30a3bc 100644 (file)
@@ -313,7 +313,7 @@ void title(void)
                   Menu::set_current(main_menu);
                   break;
                 case MNID_CREDITS:
-                  display_text_file("CREDITS", bkg_title);
+                  display_text_file("CREDITS", bkg_title, SCROLL_SPEED_CREDITS);
                   Menu::set_current(main_menu);
                   break;
                 case MNID_QUITMAINMENU:
index f10d81e..1971450 100644 (file)
@@ -683,9 +683,9 @@ WorldMap::update(float delta)
                     if (!level->extro_filename.empty())
                       { // Display final credits and go back to the main menu
                         display_text_file(level->extro_filename,
-                                          "/images/background/extro.jpg");
+                                          "/images/background/extro.jpg", SCROLL_SPEED_MESSAGE);
                         display_text_file("CREDITS",
-                                          "/images/background/oiltux.jpg");
+                                          "/images/background/oiltux.jpg", SCROLL_SPEED_CREDITS);
                         quit = true;
                       }
                   }