From: Ricardo Cruz Date: Wed, 19 May 2004 10:29:39 +0000 (+0000) Subject: Level's draw_bg() now takes full care of the background drawing. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e2ce26bad9efee4e708f9238a1721c558b87a780;p=supertux.git Level's draw_bg() now takes full care of the background drawing. SVN-Revision: 1269 --- diff --git a/src/gameloop.cpp b/src/gameloop.cpp index cb670d5ff..190700c50 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -145,10 +145,7 @@ GameSession::levelintro(void) char str[60]; - if (get_level()->img_bkgd) - get_level()->draw_bg(); - else - drawgradient(get_level()->bkgd_top, get_level()->bkgd_bottom); + get_level()->draw_bg(); sprintf(str, "%s", world->get_level()->name.c_str()); gold_text->drawf(str, 0, 220, A_HMIDDLE, A_TOP, 1); @@ -719,10 +716,7 @@ GameSession::drawresultscreen(void) { char str[80]; - if (get_level()->img_bkgd) - get_level()->draw_bg(); - else - drawgradient(get_level()->bkgd_top, get_level()->bkgd_bottom); + get_level()->draw_bg(); blue_text->drawf("Result:", 0, 200, A_HMIDDLE, A_TOP, 1); diff --git a/src/level.cpp b/src/level.cpp index ff38e8df1..24deca628 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -762,14 +762,21 @@ Level::change(float x, float y, int tm, unsigned int c) void Level::draw_bg() { - // Tile background horizontally - int sx = (int)((float)scroll_x * ((float)bkgd_speed/100.0f)) % img_bkgd->w; - int sy = (int)((float)scroll_y * ((float)bkgd_speed/100.0f)) % img_bkgd->h; - for (int x = 0; (x-1)*img_bkgd->w <= screen->w; x++) - for (int y = 0; (y-1)*img_bkgd->h <= screen->h; y++) - img_bkgd->draw_part(x == 0 ? sx : 0, y == 0 ? sy : 0, - x == 0 ? 0 : (img_bkgd->w * x) - sx, y == 0 ? 0 : (img_bkgd->h * y) - sy, - x == 0 ? img_bkgd->w - sx : img_bkgd->w, y == 0 ? img_bkgd->h - sy : img_bkgd->h); + if(img_bkgd) + { + // Tile background horizontally + int sx = (int)((float)scroll_x * ((float)bkgd_speed/100.0f)) % img_bkgd->w; + int sy = (int)((float)scroll_y * ((float)bkgd_speed/100.0f)) % img_bkgd->h; + for (int x = 0; (x-1)*img_bkgd->w <= screen->w; x++) + for (int y = 0; (y-1)*img_bkgd->h <= screen->h; y++) + img_bkgd->draw_part(x == 0 ? sx : 0, y == 0 ? sy : 0, + x == 0 ? 0 : (img_bkgd->w * x) - sx, y == 0 ? 0 : (img_bkgd->h * y) - sy, + x == 0 ? img_bkgd->w - sx : img_bkgd->w, y == 0 ? img_bkgd->h - sy : img_bkgd->h); + } + else + { + drawgradient(bkgd_top, bkgd_bottom); + } } void diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index 9b4b1004c..47a39ab19 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -927,10 +927,7 @@ void le_drawlevel() Uint8 a; /* Draw the real background */ - if (le_world->get_level()->img_bkgd) - le_world->get_level()->draw_bg(); - else - drawgradient(le_world->get_level()->bkgd_top, le_world->get_level()->bkgd_bottom); + le_world->get_level()->draw_bg(); if(le_current.IsTile()) {