- more resolution fixes
authorRyan Flegel <rflegel@gmail.com>
Fri, 14 May 2004 21:49:30 +0000 (21:49 +0000)
committerRyan Flegel <rflegel@gmail.com>
Fri, 14 May 2004 21:49:30 +0000 (21:49 +0000)
SVN-Revision: 1182

src/gameloop.cpp
src/level.cpp
src/level.h
src/screen.cpp
src/title.cpp
src/world.cpp

index 9c52c9f..251dafd 100644 (file)
@@ -146,7 +146,7 @@ GameSession::levelintro(void)
   char str[60];
  
   if (get_level()->img_bkgd)
-    get_level()->img_bkgd->draw(0, 0);
+    get_level()->draw_bg();
   else
     drawgradient(get_level()->bkgd_top, get_level()->bkgd_bottom);
 
@@ -721,7 +721,7 @@ GameSession::drawendscreen()
   char str[80];
 
   if (get_level()->img_bkgd)
-    get_level()->img_bkgd->draw(0, 0);
+    get_level()->draw_bg();
   else
     drawgradient(get_level()->bkgd_top, get_level()->bkgd_bottom);
 
@@ -745,7 +745,7 @@ GameSession::drawresultscreen(void)
   char str[80];
 
   if (get_level()->img_bkgd)
-    get_level()->img_bkgd->draw(0, 0);
+    get_level()->draw_bg();
   else
     drawgradient(get_level()->bkgd_top, get_level()->bkgd_bottom);
 
index c8ef15d..ce2414f 100644 (file)
@@ -739,6 +739,16 @@ 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;
+  for (int i = 0; (i-1)*img_bkgd->w <= screen->w; i++)
+    img_bkgd->draw_part(i == 0 ? sx : 0, 0,
+                        i == 0 ? 0 : (img_bkgd->w * i) - sx, 0,
+                        i == 0 ? img_bkgd->w - sx : img_bkgd->w, img_bkgd->h);
+}
+
 void
 Level::load_song()
 {
index 3b08ec7..0a023a5 100644 (file)
@@ -136,6 +136,9 @@ class Level
   void change_width (int new_width);
   void change_height (int new_height);
 
+  /* Draw background */
+  void draw_bg();
+
   /** Return the id of the tile at position x/y */
   unsigned int gettileid(float x, float y) const;
   /** returns the id of the tile at position x,y
index df1b53f..fa685b1 100644 (file)
@@ -72,10 +72,10 @@ void drawgradient(Color top_clr, Color bot_clr)
       glBegin(GL_QUADS);
       glColor3ub(top_clr.red, top_clr.green, top_clr.blue);
       glVertex2f(0, 0);
-      glVertex2f(640, 0);
+      glVertex2f(screen->w, 0);
       glColor3ub(bot_clr.red, bot_clr.green, bot_clr.blue);
-      glVertex2f(640, 480);
-      glVertex2f(0, 480);
+      glVertex2f(screen->w, screen->h);
+      glVertex2f(0, screen->h);
       glEnd();
     }
   else
index f9e2ef5..1425031 100644 (file)
@@ -271,7 +271,7 @@ void title(void)
       draw_demo(&session, frame_ratio);
       
       if (Menu::current() == main_menu)
-        logo->draw( 160, 30);
+        logo->draw(screen->w/2 - logo->w/2, 30);
 
       white_small_text->draw(" SuperTux " VERSION "\n"
                              "Copyright (c) 2003 SuperTux Devel Team\n"
index bd1cc93..a62ecd3 100644 (file)
@@ -178,21 +178,10 @@ World::draw()
   int y,x;
 
   /* Draw the real background */
+  drawgradient(level->bkgd_top, level->bkgd_bottom);
   if(level->img_bkgd)
-    {
-      // Tile background horizontally
-      int sx = (int)((float)scroll_x * ((float)level->bkgd_speed/100.0f)) % level->img_bkgd->w;
-      for (int i = 0; (i-1)*level->img_bkgd->w <= screen->w; i++)
-        {
-          level->img_bkgd->draw_part(i == 0 ? sx : 0, 0,
-                                     i == 0 ? 0 : (level->img_bkgd->w * i) - sx, 0,
-                                     i == 0 ? level->img_bkgd->w - sx : level->img_bkgd->w, level->img_bkgd->h);
-        }
-    }
-  else
-    {
-      drawgradient(level->bkgd_top, level->bkgd_bottom);
-    }
+      level->draw_bg();
+
     
   /* Draw particle systems (background) */
   std::vector<ParticleSystem*>::iterator p;