From: Ricardo Cruz Date: Tue, 13 Apr 2004 11:34:54 +0000 (+0000) Subject: Just changed each bkgd_top_* and bkgd_bottom_* to be Color structs that can be found... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=05c111b7eef84472f8a13e11b5385b5f783e3a6c;p=supertux.git Just changed each bkgd_top_* and bkgd_bottom_* to be Color structs that can be found at screen.h. Requested by Ingo Ruhnke. Ingo, I haven't even tried to change the level files, since I don't have any clue about lisp. Please, do that yourself. SVN-Revision: 515 --- diff --git a/src/gameobjs.cpp b/src/gameobjs.cpp index 00e254339..f37bc2270 100644 --- a/src/gameobjs.cpp +++ b/src/gameobjs.cpp @@ -137,7 +137,7 @@ BouncyBrick::draw() { fillrect(base.x - scroll_x, base.y, 32,32, - plevel->bkgd_top_red, plevel->bkgd_top_green, plevel->bkgd_top_blue, 0); + plevel->bkgd_top.red, plevel->bkgd_top.green, plevel->bkgd_top.blue, 0); // FIXME: doesn't respect the gradient, futhermore is this necessary at all?? } else diff --git a/src/level.cpp b/src/level.cpp index 4a3b08488..bff9411ca 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -201,12 +201,12 @@ Level::init_defaults() width = 21; time_left = 100; gravity = 10.; - bkgd_top_red = 0; - bkgd_top_green = 0; - bkgd_top_blue = 0; - bkgd_bottom_red = 0; - bkgd_bottom_green = 0; - bkgd_bottom_blue = 0; + bkgd_top.red = 0; + bkgd_top.green = 0; + bkgd_top.blue = 0; + bkgd_bottom.red = 255; + bkgd_bottom.green = 255; + bkgd_bottom.blue = 255; endpos = 0; for(int i = 0; i < 15; ++i) @@ -277,12 +277,12 @@ Level::load(const std::string& filename) reader.read_int("version", &version); reader.read_int("width", &width); reader.read_int("time", &time_left); - reader.read_int("bkgd_top_red", &bkgd_top_red); - reader.read_int("bkgd_top_green", &bkgd_top_green); - reader.read_int("bkgd_top_blue", &bkgd_top_blue); - reader.read_int("bkgd_bottom_red", &bkgd_bottom_red); - reader.read_int("bkgd_bottom_green", &bkgd_bottom_green); - reader.read_int("bkgd_bottom_blue", &bkgd_bottom_blue); + reader.read_int("bkgd_top_red", &bkgd_top.red); + reader.read_int("bkgd_top_green", &bkgd_top.green); + reader.read_int("bkgd_top_blue", &bkgd_top.blue); + reader.read_int("bkgd_bottom_red", &bkgd_bottom.red); + reader.read_int("bkgd_bottom_green", &bkgd_bottom.green); + reader.read_int("bkgd_bottom_blue", &bkgd_bottom.blue); reader.read_float("gravity", &gravity); reader.read_string("name", &name); reader.read_string("author", &author); @@ -476,12 +476,12 @@ Level::save(const char * subset, int level) fprintf(fi," (music \"%s\")\n", song_title.c_str()); fprintf(fi," (background \"%s\")\n", bkgd_image.c_str()); fprintf(fi," (particle_system \"%s\")\n", particle_system.c_str()); - fprintf(fi," (bkgd_top_red %d)\n", bkgd_top_red); - fprintf(fi," (bkgd_top_green %d)\n", bkgd_top_green); - fprintf(fi," (bkgd_top_blue %d)\n", bkgd_top_blue); - fprintf(fi," (bkgd_bottom_red %d)\n", bkgd_bottom_red); - fprintf(fi," (bkgd_bottom_green %d)\n", bkgd_bottom_green); - fprintf(fi," (bkgd_bottom_blue %d)\n", bkgd_bottom_blue); + fprintf(fi," (bkgd_top_red %d)\n", bkgd_top.red); + fprintf(fi," (bkgd_top_green %d)\n", bkgd_top.green); + fprintf(fi," (bkgd_top_blue %d)\n", bkgd_top.blue); + fprintf(fi," (bkgd_bottom_red %d)\n", bkgd_bottom.red); + fprintf(fi," (bkgd_bottom_green %d)\n", bkgd_bottom.green); + fprintf(fi," (bkgd_bottom_blue %d)\n", bkgd_bottom.blue); fprintf(fi," (time %d)\n", time_left); fprintf(fi," (width %d)\n", width); fprintf(fi," (gravity %2.1f)\n", gravity); diff --git a/src/level.h b/src/level.h index 389555a98..887d0aa05 100644 --- a/src/level.h +++ b/src/level.h @@ -65,12 +65,8 @@ class Level unsigned int* ia_tiles[15]; /* Tiles which can interact in the game (solids for example)*/ unsigned int* fg_tiles[15]; /* Tiles in the foreground */ int time_left; - int bkgd_top_red; - int bkgd_top_green; - int bkgd_top_blue; - int bkgd_bottom_red; - int bkgd_bottom_green; - int bkgd_bottom_blue; + Color bkgd_top; + Color bkgd_bottom; int width; int endpos; float gravity; diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index 6185882bb..1db3721f8 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -487,17 +487,17 @@ void update_level_settings_menu() level_settings_menu->item[8].change_input(str); sprintf(str,"%2.0f",le_current_level->gravity); level_settings_menu->item[9].change_input(str); - sprintf(str,"%d",le_current_level->bkgd_top_red); + sprintf(str,"%d",le_current_level->bkgd_top.red); level_settings_menu->item[10].change_input(str); - sprintf(str,"%d",le_current_level->bkgd_top_green); + sprintf(str,"%d",le_current_level->bkgd_top.green); level_settings_menu->item[11].change_input(str); - sprintf(str,"%d",le_current_level->bkgd_top_blue); + sprintf(str,"%d",le_current_level->bkgd_top.blue); level_settings_menu->item[12].change_input(str); - sprintf(str,"%d",le_current_level->bkgd_bottom_red); + sprintf(str,"%d",le_current_level->bkgd_bottom.red); level_settings_menu->item[13].change_input(str); - sprintf(str,"%d",le_current_level->bkgd_bottom_green); + sprintf(str,"%d",le_current_level->bkgd_bottom.green); level_settings_menu->item[14].change_input(str); - sprintf(str,"%d",le_current_level->bkgd_bottom_blue); + sprintf(str,"%d",le_current_level->bkgd_bottom.blue); level_settings_menu->item[15].change_input(str); } @@ -538,12 +538,12 @@ void apply_level_settings_menu() le_current_level->change_size(atoi(level_settings_menu->item[7].input)); le_current_level->time_left = atoi(level_settings_menu->item[8].input); le_current_level->gravity = atof(level_settings_menu->item[9].input); - le_current_level->bkgd_top_red = atoi(level_settings_menu->item[10].input); - le_current_level->bkgd_top_green = atoi(level_settings_menu->item[11].input); - le_current_level->bkgd_top_blue = atoi(level_settings_menu->item[12].input); - le_current_level->bkgd_bottom_red = atoi(level_settings_menu->item[13].input); - le_current_level->bkgd_bottom_green = atoi(level_settings_menu->item[14].input); - le_current_level->bkgd_bottom_blue = atoi(level_settings_menu->item[15].input); + le_current_level->bkgd_top.red = atoi(level_settings_menu->item[10].input); + le_current_level->bkgd_top.green = atoi(level_settings_menu->item[11].input); + le_current_level->bkgd_top.blue = atoi(level_settings_menu->item[12].input); + le_current_level->bkgd_bottom.red = atoi(level_settings_menu->item[13].input); + le_current_level->bkgd_bottom.green = atoi(level_settings_menu->item[14].input); + le_current_level->bkgd_bottom.blue = atoi(level_settings_menu->item[15].input); } void save_subset_settings_menu() @@ -701,8 +701,7 @@ void le_drawlevel() } else { - drawgradient(le_current_level->bkgd_top_red, le_current_level->bkgd_top_green, le_current_level->bkgd_top_blue, - le_current_level->bkgd_bottom_red, le_current_level->bkgd_bottom_green, le_current_level->bkgd_bottom_blue); + drawgradient(le_current_level->bkgd_top, le_current_level->bkgd_bottom); } /* clearscreen(current_level.bkgd_red, current_level.bkgd_green, current_level.bkgd_blue); */ diff --git a/src/screen.cpp b/src/screen.cpp index 7adeae4a1..d3e762d87 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -56,16 +56,16 @@ void clearscreen(int r, int g, int b) /* --- DRAWS A VERTICAL GRADIENT --- */ -void drawgradient(int top_r, int top_g, int top_b, int bot_r, int bot_g, int bot_b) +void drawgradient(Color top_clr, Color bot_clr) { #ifndef NOOPENGL if(use_gl) { glBegin(GL_QUADS); - glColor3ub(top_r, top_g, top_b); + glColor3ub(top_clr.red, top_clr.green, top_clr.blue); glVertex2f(0, 0); glVertex2f(640, 0); - glColor3ub(bot_r, bot_g, bot_b); + glColor3ub(bot_clr.red, bot_clr.green, bot_clr.blue); glVertex2f(640, 480); glVertex2f(0, 480); glEnd(); @@ -75,9 +75,9 @@ void drawgradient(int top_r, int top_g, int top_b, int bot_r, int bot_g, int bot #endif for(float y = 0; y < 480; y += 2) - fillrect(0, (int)y, 640, 2, (int)(((float)(top_r-bot_r)/640) * y + top_r), - (int)(((float)(top_g-bot_g)/640) * y + top_g), - (int)(((float)(top_b-bot_b)/640) * y + top_b), 255); + fillrect(0, (int)y, 640, 2, (int)(((float)(top_clr.red-bot_clr.red)/640) * y + top_clr.red), + (int)(((float)(top_clr.green-bot_clr.green)/640) * y + top_clr.green), + (int)(((float)(top_clr.blue-bot_clr.blue)/640) * y + top_clr.blue), 255); /* calculates the color for each line, based in the generic equation for functions: y = mx + b */ #ifndef NOOPENGL diff --git a/src/screen.h b/src/screen.h index f779dc5fd..8231c5478 100644 --- a/src/screen.h +++ b/src/screen.h @@ -24,9 +24,14 @@ #define USE_ALPHA 0 #define IGNORE_ALPHA 1 +struct Color +{ +int red, green, blue; +}; + void drawline(int x1, int y1, int x2, int y2, int r, int g, int b, int a); void clearscreen(int r, int g, int b); -void drawgradient(int top_r, int top_g, int top_b, int bot_r, int bot_g, int bot_b); +void drawgradient(Color top_clr, Color bot_clr); void fillrect(float x, float y, float w, float h, int r, int g, int b, int a); void updatescreen(void); void flipscreen(void); diff --git a/src/world.cpp b/src/world.cpp index 7c44e552d..29f63ee9d 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -134,8 +134,7 @@ World::draw() } else { - drawgradient(level->bkgd_top_red, level->bkgd_top_green, level->bkgd_top_blue, - level->bkgd_bottom_red, level->bkgd_bottom_green, level->bkgd_bottom_blue); + drawgradient(level->bkgd_top, level->bkgd_bottom); } /* Draw particle systems (background) */