From a53b840b2644f292a348533f86745588c08424d9 Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Wed, 28 Apr 2004 14:58:24 +0000 Subject: [PATCH] Made display_text_file() to get the scroll speed as an argument. This way we can make the intro slower than the credits, for instance. It was just impossible to read them. 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 | 5 +++++ src/intro.cpp | 2 +- src/text.cpp | 33 +++++++++++++++++---------------- src/text.h | 4 ++-- src/title.cpp | 2 +- src/worldmap.cpp | 4 ++-- 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/defines.h b/src/defines.h index c2c71a7e1..163f1bdd3 100644 --- a/src/defines.h +++ b/src/defines.h @@ -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 diff --git a/src/intro.cpp b/src/intro.cpp index a994f9935..b8a6c4f4d 100644 --- a/src/intro.cpp +++ b/src/intro.cpp @@ -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); } diff --git a/src/text.cpp b/src/text.cpp index ee0e7b882..4ef3cfe51 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -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; diff --git a/src/text.h b/src/text.h index d82a25681..87066d7e2 100644 --- a/src/text.h +++ b/src/text.h @@ -24,8 +24,8 @@ #include #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 { diff --git a/src/title.cpp b/src/title.cpp index cb3a512dc..d30a3bc36 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -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: diff --git a/src/worldmap.cpp b/src/worldmap.cpp index f10d81e11..1971450f7 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -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; } } -- 2.11.0