- added geometry option which allows SuperTux to run at any resolution
authorIngo Ruhnke <grumbel@gmx.de>
Mon, 4 Apr 2005 16:26:14 +0000 (16:26 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Mon, 4 Apr 2005 16:26:14 +0000 (16:26 +0000)
SVN-Revision: 2334

26 files changed:
lib/app/globals.cpp
lib/app/globals.h
lib/app/setup.cpp
lib/audio/sound_manager.cpp
lib/gui/button.cpp
lib/gui/menu.cpp
lib/gui/mousecursor.cpp
lib/video/drawing_context.cpp
lib/video/drawing_context.h
lib/video/screen.cpp
src/gameloop.cpp
src/leveleditor.cpp
src/misc.cpp
src/object/background.cpp
src/object/bullet.cpp
src/object/camera.cpp
src/object/fireworks.cpp
src/object/gameobjs.cpp
src/object/particlesystem.cpp
src/object/player.cpp
src/object/tilemap.cpp
src/statistics.cpp
src/supertux.cpp
src/textscroller.cpp
src/title.cpp
src/worldmap.cpp

index 67819d0..35ae5d0 100644 (file)
@@ -33,7 +33,10 @@ std::string datadir;
 std::string package_symbol_name;
 std::string package_name;
 std::string package_version;
-  
+
+int screen_width  = SCREEN_WIDTH;
+int screen_height = SCREEN_HEIGHT;
+
 JoystickKeymap::JoystickKeymap()
 {
   a_button     = 0;
index 83d57ed..edc6416 100644 (file)
@@ -62,9 +62,14 @@ namespace SuperTux
 
   extern MouseCursor * mouse_cursor;
 
+#define SCREEN_WIDTH  800
+#define SCREEN_HEIGHT 600
+
   extern bool use_gl;
   extern bool use_joystick;
   extern bool use_fullscreen;
+  extern int  screen_width;
+  extern int  screen_height;
   extern bool debug_mode;
   extern bool show_fps;
   extern bool debug_grid;
index c7972c4..5c8d09e 100644 (file)
@@ -488,7 +488,8 @@ void Setup::video_gl(unsigned int screen_w, unsigned int screen_h)
   glViewport(0, 0, screen->w, screen->h);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
-  glOrtho(0, screen->w, screen->h, 0, -1.0, 1.0);
+  glOrtho(0, 800, 600, 0, -1.0, 1.0);
+  //glOrtho(0, 800SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
 
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
@@ -696,6 +697,16 @@ void Setup::parseargs(int argc, char * argv[])
         {
           use_fullscreen = false;
         }
+      else if (strcmp(argv[i], "--geometry") == 0 ||
+               strcmp(argv[i], "-g") == 0)
+        {
+          assert(i+1 < argc);
+          if (sscanf(argv[++i],
+                     "%dx%d", &screen_width, &screen_height) != 2)
+            {
+              puts("Warning: Invalid geometry spec, should be \"WIDTHxHEIGHT\"");
+            }
+        }
       else if (strcmp(argv[i], "--joystick") == 0 || strcmp(argv[i], "-j") == 0)
         {
           assert(i+1 < argc);
@@ -802,6 +813,7 @@ void Setup::parseargs(int argc, char * argv[])
                "  --opengl            If OpenGL support was compiled in, this will tell\n"
                "                      SuperTux to make use of it.\n"
                "  --sdl               Use the SDL software graphical renderer\n"
+               "  --geometry WIDTHxHEIGHT Run SuperTux in the given resolution\n"
                "\n"
                "Sound Options:\n"
                "  --disable-sound     If sound support was compiled in,  this will\n"
@@ -855,7 +867,7 @@ void usage(char * prog, int ret)
 
   /* Display the usage message: */
 
-  fprintf(fi, _("Usage: %s [--fullscreen] [--opengl] [--disable-sound] [--disable-music] [--debug] | [--usage | --help | --version] [--leveleditor] [--worldmap] [--flip-levels] FILENAME\n"),
+  fprintf(fi, _("Usage: %s [--fullscreen] [--opengl] [--geometry WIDTHxHEIGHT] [--disable-sound] [--disable-music] [--debug] | [--usage | --help | --version] [--leveleditor] [--worldmap] [--flip-levels] FILENAME\n"),
           prog);
 
 
index 0243f24..2144bba 100644 (file)
@@ -72,7 +72,7 @@ SoundManager::play_sound(Mix_Chunk* sound, const Vector& pos, const Vector& pos2
   // TODO make sure this formula is good
   float distance 
     = pos2.x- pos.x;
-  int loud = int(255.0/float(screen->w*2) * fabsf(distance));
+  int loud = int(255.0/float(SCREEN_WIDTH*2) * fabsf(distance));
   if(loud > 255)
     return;
 
index b597368..93b226d 100644 (file)
@@ -55,7 +55,7 @@ Vector tanslation = -context.get_translation();
 if(state == BT_SHOW_INFO)
   {
   Vector offset;
-  if(pos.x + tanslation.x < 100 && pos.y + tanslation.y > screen->h - 20)
+  if(pos.x + tanslation.x < 100 && pos.y + tanslation.y > SCREEN_HEIGHT - 20)
     offset = Vector(size.x, - 10);
   else if(pos.x + tanslation.x < 100)
     offset = Vector(size.x, 0);
@@ -176,8 +176,8 @@ switch(event.type)
 
     if(mouse_left_button)
       {
-      pos.x += event.motion.xrel;
-      pos.y += event.motion.yrel;
+      pos.x += int(event.motion.xrel * float(SCREEN_WIDTH)/screen->w); 
+      pos.y += int(event.motion.yrel * float(SCREEN_HEIGHT)/screen->h);
       caught_event = true;
       }
     if(event.button.x > pos.x-12 && event.button.x < pos.x+16 + buttons_box.x*buttons_size.x &&
index 57643ef..83c1664 100644 (file)
@@ -298,8 +298,8 @@ Menu::Menu()
   delete_character = 0;
   mn_input_char = '\0';
 
-  pos_x        = screen->w/2;
-  pos_y        = screen->h/2;
+  pos_x        = SCREEN_WIDTH/2;
+  pos_y        = SCREEN_HEIGHT/2;
   arrange_left = 0;
   active_item  = 0;
   effect.init(false);
@@ -526,7 +526,7 @@ Menu::draw_item(DrawingContext& context,
     case MN_DEACTIVE:
       {
         context.draw_text(deactive_font, pitem.text,
-                          Vector(screen->w/2, y_pos - int(deactive_font->get_height()/2)),
+                          Vector(SCREEN_WIDTH/2, y_pos - int(deactive_font->get_height()/2)),
                           CENTER_ALLIGN, LAYER_GUI);
         break;
       }
@@ -546,7 +546,7 @@ Menu::draw_item(DrawingContext& context,
     case MN_LABEL:
       {
         context.draw_text(label_font, pitem.text,
-                          Vector(screen->w/2, y_pos - int(label_font->get_height()/2)),
+                          Vector(SCREEN_WIDTH/2, y_pos - int(label_font->get_height()/2)),
                           CENTER_ALLIGN, LAYER_GUI);
         break;
       }
@@ -556,7 +556,7 @@ Menu::draw_item(DrawingContext& context,
     case MN_CONTROLFIELD_JS:
       {
         int width = text_width + input_width + 5;
-        int text_pos = screen->w/2 - width/2;
+        int text_pos = SCREEN_WIDTH/2 - width/2;
         int input_pos = text_pos + text_width + 10;
 
         context.draw_filled_rect(
@@ -621,17 +621,17 @@ Menu::draw_item(DrawingContext& context,
           Color(0,0,0,128), LAYER_GUI - 5);
 
         context.draw_text(text_font, pitem.list[pitem.selected],
-                                 Vector(screen->w/2 + text_pos, y_pos - int(text_font->get_height()/2)),
+                                 Vector(SCREEN_WIDTH/2 + text_pos, y_pos - int(text_font->get_height()/2)),
                                  CENTER_ALLIGN, LAYER_GUI);
         context.draw_text(text_font, pitem.text,
-                                 Vector(screen->w/2  + list_pos_2/2, y_pos - int(text_font->get_height()/2)),
+                                 Vector(SCREEN_WIDTH/2  + list_pos_2/2, y_pos - int(text_font->get_height()/2)),
                                  CENTER_ALLIGN, LAYER_GUI);
         break;
       }
     case MN_BACK:
       {
         context.draw_text(text_font, pitem.text,
-                          Vector(screen->w/2, y_pos - int(text_font->get_height()/2)),
+                          Vector(SCREEN_WIDTH/2, y_pos - int(text_font->get_height()/2)),
                           CENTER_ALLIGN, LAYER_GUI);
         context.draw_surface(back,
                              Vector(x_pos + text_width/2  + 16, y_pos - 8),
@@ -642,7 +642,7 @@ Menu::draw_item(DrawingContext& context,
     case MN_TOGGLE:
       {
         context.draw_text(text_font, pitem.text,
-                          Vector(screen->w/2, y_pos - (text_font->get_height()/2)),
+                          Vector(SCREEN_WIDTH/2, y_pos - (text_font->get_height()/2)),
                           CENTER_ALLIGN, LAYER_GUI);
 
         if(pitem.toggled)
@@ -657,13 +657,13 @@ Menu::draw_item(DrawingContext& context,
       }
     case MN_ACTION:
       context.draw_text(text_font, pitem.text,
-                        Vector(screen->w/2, y_pos - int(text_font->get_height()/2)),
+                        Vector(SCREEN_WIDTH/2, y_pos - int(text_font->get_height()/2)),
                         CENTER_ALLIGN, LAYER_GUI);
       break;
 
     case MN_GOTO:
       context.draw_text(text_font, pitem.text,
-                        Vector(screen->w/2, y_pos - int(text_font->get_height()/2)),
+                        Vector(SCREEN_WIDTH/2, y_pos - int(text_font->get_height()/2)),
                         CENTER_ALLIGN, LAYER_GUI);
       break;
     }
@@ -859,8 +859,8 @@ Menu::event(SDL_Event& event)
 
     case SDL_MOUSEBUTTONDOWN:
       {
-        int x = event.motion.x;
-        int y = event.motion.y;
+        int x = int(event.motion.x * float(SCREEN_WIDTH)/screen->w);
+        int y = int(event.motion.y * float(SCREEN_HEIGHT)/screen->h);
 
         if(x > pos_x - get_width()/2 &&
             x < pos_x + get_width()/2 &&
@@ -874,8 +874,8 @@ Menu::event(SDL_Event& event)
 
     case SDL_MOUSEMOTION:
       {
-        int x = event.motion.x;
-        int y = event.motion.y;
+        int x = int(event.motion.x * float(SCREEN_WIDTH)/screen->w);
+        int y = int(event.motion.y * float(SCREEN_HEIGHT)/screen->h);
 
         if(x > pos_x - get_width()/2 &&
             x < pos_x + get_width()/2 &&
index 26df18d..2cdb7aa 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <config.h>
 
+#include "app/globals.h"
 #include "video/drawing_context.h"
 #include "gui/mousecursor.h"
 
@@ -70,6 +71,10 @@ void MouseCursor::draw(DrawingContext& context)
 
   int x,y,w,h;
   Uint8 ispressed = SDL_GetMouseState(&x,&y);
+
+  x = int(x * float(SCREEN_WIDTH)/screen->w);
+  y = int(y * float(SCREEN_HEIGHT)/screen->h);
+
   w = cursor->w / tot_frames;
   h = cursor->h / MC_STATES_NB;
   if(ispressed &SDL_BUTTON(1) || ispressed &SDL_BUTTON(2))
index 8aadf06..7ee6a9e 100644 (file)
@@ -48,7 +48,7 @@ DrawingContext::draw_surface(const Surface* surface, const Vector& position,
   request.type = SURFACE;
   request.pos = transform.apply(position);
 
-  if(request.pos.x >= screen->w || request.pos.y >= screen->h
+  if(request.pos.x >= SCREEN_WIDTH || request.pos.y >= SCREEN_HEIGHT
       || request.pos.x + surface->w < 0 || request.pos.y + surface->h < 0)
     return;
 
@@ -127,7 +127,7 @@ void
 DrawingContext::draw_center_text(const Font* font, const std::string& text,
     const Vector& position, int layer, uint32_t drawing_effect)
 {
-  draw_text(font, text, Vector(position.x + screen->w/2, position.y),
+  draw_text(font, text, Vector(position.x + SCREEN_WIDTH/2, position.y),
       CENTER_ALLIGN, layer, drawing_effect);
 }
 
@@ -202,10 +202,10 @@ DrawingContext::draw_gradient(DrawingRequest& request)
       glBegin(GL_QUADS);
       glColor3ub(top.red, top.green, top.blue);
       glVertex2f(0, 0);
-      glVertex2f(screen->w, 0);
+      glVertex2f(SCREEN_WIDTH, 0);
       glColor3ub(bottom.red, bottom.green, bottom.blue);
-      glVertex2f(screen->w, screen->h);
-      glVertex2f(0, screen->h);
+      glVertex2f(SCREEN_WIDTH, SCREEN_HEIGHT);
+      glVertex2f(0, SCREEN_HEIGHT);
       glEnd();
     }
   else
@@ -213,16 +213,16 @@ DrawingContext::draw_gradient(DrawingRequest& request)
 #endif
     if(&top == &bottom)
       {
-      fillrect(0, 0, screen->w, screen->h, top.red, top.green, top.blue);
+      fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, top.red, top.green, top.blue);
       }
     else
       {
-      float redstep = (float(bottom.red)-float(top.red)) / float(screen->h);
-      float greenstep = (float(bottom.green)-float(top.green)) / float(screen->h);
-      float bluestep = (float(bottom.blue) - float(top.blue)) / float(screen->h);
+      float redstep = (float(bottom.red)-float(top.red)) / float(SCREEN_HEIGHT);
+      float greenstep = (float(bottom.green)-float(top.green)) / float(SCREEN_HEIGHT);
+      float bluestep = (float(bottom.blue) - float(top.blue)) / float(SCREEN_HEIGHT);
 
-      for(float y = 0; y < screen->h; y += 2)
-        fillrect(0, (int)y, screen->w, 2,
+      for(float y = 0; y < SCREEN_HEIGHT; y += 2)
+        fillrect(0, (int)y, SCREEN_WIDTH, 2,
             int(float(top.red) + redstep * y),
             int(float(top.green) + greenstep * y),
             int(float(top.blue) + bluestep * y), 255);
index 3da8dcc..8e1dfaa 100644 (file)
@@ -72,7 +72,7 @@ namespace SuperTux
           uint32_t drawing_effect = NONE_EFFECT);
 
       /// Draws text on screen center (feed Vector.x with a 0).
-      /// This is the same as draw_text() with a screen->w/2 position and
+      /// This is the same as draw_text() with a SCREEN_WIDTH/2 position and
       /// alignment set to LEFT_ALLIGN
       void draw_center_text(const Font* font, const std::string& text,
                            const Vector& position, int layer,
index 4cef057..f5605ce 100644 (file)
@@ -127,7 +127,7 @@ void SuperTux::drawpixel(int x, int y, Uint32 pixel)
         }
     }
 
-  if(!(x < 0 || y < 0 || x > screen->w || y > screen->h))
+  if(!(x < 0 || y < 0 || x > SCREEN_WIDTH || y > SCREEN_HEIGHT))
     putpixel(screen, x, y, pixel);
 
   if ( SDL_MUSTLOCK(screen) )
@@ -287,7 +287,7 @@ void SuperTux::fadeout(int fade_time)
   while(alpha > 0)
     {
     alpha -= alpha_inc;
-    fillrect(0, 0, screen->w, screen->h, 0,0,0, (int)alpha_inc);  // left side
+    fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0,0,0, (int)alpha_inc);  // left side
                                                    
     DrawingContext context; // ugly...
     context.do_drawing();
@@ -295,31 +295,31 @@ void SuperTux::fadeout(int fade_time)
     SDL_Delay(int(LOOP_DELAY));
     }
 
-  fillrect(0, 0, screen->w, screen->h, 0, 0, 0, 255);
+  fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 255);
 
 }
 
 void SuperTux::shrink_fade(const Vector& point, int fade_time)
 {
   float left_inc  = point.x / ((float)fade_time / LOOP_DELAY);
-  float right_inc = (screen->w - point.x) / ((float)fade_time / LOOP_DELAY);
+  float right_inc = (SCREEN_WIDTH - point.x) / ((float)fade_time / LOOP_DELAY);
   float up_inc    = point.y / ((float)fade_time / LOOP_DELAY);
-  float down_inc  = (screen->h - point.y) / ((float)fade_time / LOOP_DELAY);
+  float down_inc  = (SCREEN_HEIGHT - point.y) / ((float)fade_time / LOOP_DELAY);
                                                                                 
   float left_cor = 0, right_cor = 0, up_cor = 0, down_cor = 0;
                                                                                 
-  while(left_cor < point.x && right_cor < screen->w - point.x &&
-      up_cor < point.y && down_cor < screen->h - point.y)
+  while(left_cor < point.x && right_cor < SCREEN_WIDTH - point.x &&
+      up_cor < point.y && down_cor < SCREEN_HEIGHT - point.y)
   {
     left_cor  += left_inc;
     right_cor += right_inc;
     up_cor    += up_inc;
     down_cor  += down_inc;
                                                                                 
-    fillrect(0, 0, left_cor, screen->h, 0,0,0);  // left side
-    fillrect(screen->w - right_cor, 0, right_cor, screen->h, 0,0,0);  // right side
-    fillrect(0, 0, screen->w, up_cor, 0,0,0);  // up side
-    fillrect(0, screen->h - down_cor, screen->w, down_cor+1, 0,0,0);  // down side                                                                                
+    fillrect(0, 0, left_cor, SCREEN_HEIGHT, 0,0,0);  // left side
+    fillrect(SCREEN_WIDTH - right_cor, 0, right_cor, SCREEN_HEIGHT, 0,0,0);  // right side
+    fillrect(0, 0, SCREEN_WIDTH, up_cor, 0,0,0);  // up side
+    fillrect(0, SCREEN_HEIGHT - down_cor, SCREEN_WIDTH, down_cor+1, 0,0,0);  // down side                                                                                
     DrawingContext context; // ugly...
     context.do_drawing();
     
index 642a436..ca9a0bc 100644 (file)
@@ -159,20 +159,20 @@ GameSession::levelintro()
     }
   }
 
-//  context.draw_text(gold_text, level->get_name(), Vector(screen->w/2, 160),
+//  context.draw_text(gold_text, level->get_name(), Vector(SCREEN_WIDTH/2, 160),
 //      CENTER_ALLIGN, LAYER_FOREGROUND1);
   context.draw_center_text(gold_text, level->get_name(), Vector(0, 160),
       LAYER_FOREGROUND1);
 
   sprintf(str, "TUX x %d", player_status.lives);
-  context.draw_text(white_text, str, Vector(screen->w/2, 210),
+  context.draw_text(white_text, str, Vector(SCREEN_WIDTH/2, 210),
       CENTER_ALLIGN, LAYER_FOREGROUND1);
 
   if((level->get_author().size()) && (level->get_author() != "SuperTux Team"))
     //TODO make author check case/blank-insensitive
     context.draw_text(white_small_text,
       std::string(_("contributed by ")) + level->get_author(), 
-      Vector(screen->w/2, 350), CENTER_ALLIGN, LAYER_FOREGROUND1);
+      Vector(SCREEN_WIDTH/2, 350), CENTER_ALLIGN, LAYER_FOREGROUND1);
 
 
   if(best_level_statistics != NULL)
@@ -324,7 +324,7 @@ GameSession::process_events()
                           snprintf(buf, sizeof(buf), "P: %4.1f,%4.1f",
                               tux.get_pos().x, tux.get_pos().y);
                           context->draw_text(white_text, buf,
-                              Vector(0, screen->h - white_text->get_height()),
+                              Vector(0, SCREEN_HEIGHT - white_text->get_height()),
                               LEFT_ALLIGN, LAYER_FOREGROUND1);
                           context->do_drawing();
                           SDL_Delay(1000);
@@ -510,7 +510,7 @@ GameSession::handle_cheats()
   if(compare_last(last_keys, "gotoend")) {
     // goes to the end of the level
     tux.move(Vector(
-          (currentsector->solids->get_width()*32) - (screen->w*2), 0));
+          (currentsector->solids->get_width()*32) - (SCREEN_WIDTH*2), 0));
     currentsector->camera->reset(
         Vector(tux.get_pos().x, tux.get_pos().y));
     last_keys.clear();
@@ -598,29 +598,29 @@ GameSession::draw()
 void
 GameSession::draw_pause()
 {
-  int x = screen->h / 20;
+  int x = SCREEN_HEIGHT / 20;
   for(int i = 0; i < x; ++i) {
     context->draw_filled_rect(
-        Vector(i % 2 ? (pause_menu_frame * i)%screen->w :
-          -((pause_menu_frame * i)%screen->w)
-          ,(i*20+pause_menu_frame)%screen->h),
-        Vector(screen->w,10),
+        Vector(i % 2 ? (pause_menu_frame * i)%SCREEN_WIDTH :
+          -((pause_menu_frame * i)%SCREEN_WIDTH)
+          ,(i*20+pause_menu_frame)%SCREEN_HEIGHT),
+        Vector(SCREEN_WIDTH,10),
         Color(20,20,20, rand() % 20 + 1), LAYER_FOREGROUND1+1);
   }
   context->draw_filled_rect(
-      Vector(0,0), Vector(screen->w, screen->h),
+      Vector(0,0), Vector(SCREEN_WIDTH, SCREEN_HEIGHT),
       Color(rand() % 50, rand() % 50, rand() % 50, 128), LAYER_FOREGROUND1);
   context->draw_text(blue_text, _("PAUSE - Press 'P' To Play"),
-      Vector(screen->w/2, 230), CENTER_ALLIGN, LAYER_FOREGROUND1+2);
+      Vector(SCREEN_WIDTH/2, 230), CENTER_ALLIGN, LAYER_FOREGROUND1+2);
 
   const char* str1 = _("Playing: ");
   const char* str2 = level->get_name().c_str();
 
   context->draw_text(blue_text, str1,
-      Vector((screen->w - (blue_text->get_text_width(str1) + white_text->get_text_width(str2)))/2, 340),
+      Vector((SCREEN_WIDTH - (blue_text->get_text_width(str1) + white_text->get_text_width(str2)))/2, 340),
       LEFT_ALLIGN, LAYER_FOREGROUND1+2);
   context->draw_text(white_text, str2,
-      Vector(((screen->w - (blue_text->get_text_width(str1) + white_text->get_text_width(str2)))/2)+blue_text->get_text_width(str1), 340),
+      Vector(((SCREEN_WIDTH - (blue_text->get_text_width(str1) + white_text->get_text_width(str2)))/2)+blue_text->get_text_width(str1), 340),
       LEFT_ALLIGN, LAYER_FOREGROUND1+2);
 }
   
@@ -838,52 +838,52 @@ GameSession::drawstatus(DrawingContext& context)
     }
 
   if(time_left.get_timeleft() < 0) {
-    context.draw_text(white_text, _("TIME's UP"), Vector(screen->w/2, 0),
+    context.draw_text(white_text, _("TIME's UP"), Vector(SCREEN_WIDTH/2, 0),
         CENTER_ALLIGN, LAYER_FOREGROUND1);
   } else if (time_left.get_timeleft() > TIME_WARNING
       || int(global_time * 2.5) % 2) {
     sprintf(str, " %d", int(time_left.get_timeleft()));
     context.draw_text(white_text, _("TIME"),
-        Vector(screen->w/2, 0), CENTER_ALLIGN, LAYER_FOREGROUND1);
+        Vector(SCREEN_WIDTH/2, 0), CENTER_ALLIGN, LAYER_FOREGROUND1);
     context.draw_text(gold_text, str,
-        Vector(screen->w/2 + 4*16, 0), CENTER_ALLIGN, LAYER_FOREGROUND1);
+        Vector(SCREEN_WIDTH/2 + 4*16, 0), CENTER_ALLIGN, LAYER_FOREGROUND1);
   }
 
   sprintf(str, " %d", player_status.distros);
   context.draw_text(white_text, _("COINS"),
-      Vector(screen->w - white_text->get_text_width(_("COINS"))-white_text->get_text_width("   99"), 0),
+      Vector(SCREEN_WIDTH - white_text->get_text_width(_("COINS"))-white_text->get_text_width("   99"), 0),
         LEFT_ALLIGN, LAYER_FOREGROUND1);
   context.draw_text(gold_text, str,
-      Vector(screen->w - gold_text->get_text_width(" 99"), 0),LEFT_ALLIGN, LAYER_FOREGROUND1);
+      Vector(SCREEN_WIDTH - gold_text->get_text_width(" 99"), 0),LEFT_ALLIGN, LAYER_FOREGROUND1);
 
   if (player_status.lives >= 5)
     {
       sprintf(str, "%dx", player_status.lives);
-      float x = screen->w - gold_text->get_text_width(str) - tux_life->w;
+      float x = SCREEN_WIDTH - gold_text->get_text_width(str) - tux_life->w;
       context.draw_text(gold_text, str, Vector(x, 20), LEFT_ALLIGN, LAYER_FOREGROUND1);
-      context.draw_surface(tux_life, Vector(screen->w - 16, 20),
+      context.draw_surface(tux_life, Vector(SCREEN_WIDTH - 16, 20),
           LAYER_FOREGROUND1);
     }
   else
     {
       for(int i= 0; i < player_status.lives; ++i)
         context.draw_surface(tux_life, 
-            Vector(screen->w - tux_life->w*4 +(tux_life->w*i), 20),
+            Vector(SCREEN_WIDTH - tux_life->w*4 +(tux_life->w*i), 20),
             LAYER_FOREGROUND1);
     }
 
   context.draw_text(white_text, _("LIVES"),
-      Vector(screen->w - white_text->get_text_width(_("LIVES")) - white_text->get_text_width("   99"), 20),
+      Vector(SCREEN_WIDTH - white_text->get_text_width(_("LIVES")) - white_text->get_text_width("   99"), 20),
       LEFT_ALLIGN, LAYER_FOREGROUND1);
 
   if(show_fps)
     {
       sprintf(str, "%2.1f", fps_fps);
       context.draw_text(white_text, "FPS", 
-          Vector(screen->w - white_text->get_text_width("FPS     "), 40),
+          Vector(SCREEN_WIDTH - white_text->get_text_width("FPS     "), 40),
           LEFT_ALLIGN, LAYER_FOREGROUND1);
       context.draw_text(gold_text, str,
-          Vector(screen->w-4*16, 40), LEFT_ALLIGN, LAYER_FOREGROUND1);
+          Vector(SCREEN_WIDTH-4*16, 40), LEFT_ALLIGN, LAYER_FOREGROUND1);
     }
 }
 
@@ -901,14 +901,14 @@ GameSession::drawresultscreen()
     }
   }
 
-  context.draw_text(blue_text, _("Result:"), Vector(screen->w/2, 200),
+  context.draw_text(blue_text, _("Result:"), Vector(SCREEN_WIDTH/2, 200),
       CENTER_ALLIGN, LAYER_FOREGROUND1);
 
   sprintf(str, _("SCORE: %d"), global_stats.get_points(SCORE_STAT));
-  context.draw_text(gold_text, str, Vector(screen->w/2, 224), CENTER_ALLIGN, LAYER_FOREGROUND1);
+  context.draw_text(gold_text, str, Vector(SCREEN_WIDTH/2, 224), CENTER_ALLIGN, LAYER_FOREGROUND1);
 
   sprintf(str, _("COINS: %d"), player_status.distros);
-  context.draw_text(gold_text, str, Vector(screen->w/2, 256), CENTER_ALLIGN, LAYER_FOREGROUND1);
+  context.draw_text(gold_text, str, Vector(SCREEN_WIDTH/2, 256), CENTER_ALLIGN, LAYER_FOREGROUND1);
 
   context.do_drawing();
   
@@ -955,7 +955,7 @@ bool process_load_game_menu()
       fadeout(256);
       DrawingContext context;
       context.draw_text(white_text, "Loading...",
-                        Vector(screen->w/2, screen->h/2), CENTER_ALLIGN, LAYER_FOREGROUND1);
+                        Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT/2), CENTER_ALLIGN, LAYER_FOREGROUND1);
       context.do_drawing();
 
       WorldMapNS::WorldMap worldmap;
index 9ae0dc1..a6269a1 100644 (file)
@@ -99,7 +99,7 @@ LevelEditor::LevelEditor()
   /* Creating button groups */
   load_buttons_gfx();
 
-  tiles_board = new ButtonGroup(Vector(screen->w - 140, 100),
+  tiles_board = new ButtonGroup(Vector(SCREEN_WIDTH - 140, 100),
             Vector(32,32), Vector(4,8));
 
   tiles_board->add_button(Button(img_rubber_bt, _("Eraser"), SDLKey(SDLK_DELETE)), 0);
@@ -128,7 +128,7 @@ LevelEditor::LevelEditor()
                             SDLKey(SDLK_1+id)), id++);
   }
 
-  tiles_layer = new ButtonGroup(Vector(12, screen->h-64), Vector(80,20), Vector(1,3));
+  tiles_layer = new ButtonGroup(Vector(12, SCREEN_HEIGHT-64), Vector(80,20), Vector(1,3));
   tiles_layer->add_button(Button(img_foreground_bt, _("Edtit foreground tiles"),
                          SDLK_F10), LAYER_FOREGROUNDTILES);
   tiles_layer->add_button(Button(img_interactive_bt, _("Edit interactive tiles"),
@@ -136,7 +136,7 @@ LevelEditor::LevelEditor()
   tiles_layer->add_button(Button(img_background_bt, _("Edit background tiles"),
                          SDLK_F12), LAYER_BACKGROUNDTILES);
 
-  level_options = new ButtonGroup(Vector(screen->w-164, screen->h-36), Vector(32,32), Vector(5,1));
+  level_options = new ButtonGroup(Vector(SCREEN_WIDTH-164, SCREEN_HEIGHT-36), Vector(32,32), Vector(5,1));
   level_options->add_pair_of_buttons(Button(img_next_sector_bt, _("Next sector"), SDLKey(0)), BT_NEXT_SECTOR,
                  Button(img_previous_sector_bt, _("Prevous sector"), SDLKey(0)), BT_PREVIOUS_SECTOR);
   level_options->add_pair_of_buttons(Button(img_next_level_bt, _("Next level"), SDLKey(0)), BT_NEXT_LEVEL,
@@ -469,7 +469,7 @@ void LevelEditor::events()
               scroll.x = 0;
               break;
             case SDLK_END:
-              scroll.x = sector->solids->get_height()*32 - screen->w;
+              scroll.x = sector->solids->get_height()*32 - SCREEN_WIDTH;
               break;
             case SDLK_LEFT:
               scroll.x -= 80;
@@ -532,14 +532,14 @@ void LevelEditor::action()
     float width = sector->solids->get_width() * 32;
     float height = sector->solids->get_height() * 32;
 
-    if(scroll.x < -screen->w/2)
-      scroll.x = -screen->w/2;
-    if(scroll.x > width - screen->w/2)
-      scroll.x = width - screen->w/2;
-    if(scroll.y < -screen->h/2)
-      scroll.y = -screen->h/2;
-    if(scroll.y > height - screen->h/2)
-      scroll.y = height - screen->h/2;
+    if(scroll.x < -SCREEN_WIDTH/2)
+      scroll.x = -SCREEN_WIDTH/2;
+    if(scroll.x > width - SCREEN_WIDTH/2)
+      scroll.x = width - SCREEN_WIDTH/2;
+    if(scroll.y < -SCREEN_HEIGHT/2)
+      scroll.y = -SCREEN_HEIGHT/2;
+    if(scroll.y > height - SCREEN_HEIGHT/2)
+      scroll.y = height - SCREEN_HEIGHT/2;
 
     // set camera translation, since BadGuys like it
     sector->camera->set_scrolling((int)scroll.x, (int)scroll.y);
@@ -561,7 +561,7 @@ void LevelEditor::draw(DrawingContext& context)
   mouse_cursor->draw(context);
 
   // draw a filled background
-  context.draw_filled_rect(Vector(0,0), Vector(screen->w,screen->h), Color(60,60,60), LAYER_BACKGROUND0-1);
+  context.draw_filled_rect(Vector(0,0), Vector(SCREEN_WIDTH,SCREEN_HEIGHT), Color(60,60,60), LAYER_BACKGROUND0-1);
 
   if(level_name_timer.check())
     {
@@ -569,12 +569,12 @@ void LevelEditor::draw(DrawingContext& context)
     if(level_name_timer.get_timeleft() < FADING_TIME)
       context.set_alpha(int(level_name_timer.get_timeleft() * 255 / FADING_TIME));
 
-    context.draw_text(gold_text, level->name, Vector(screen->w/2, 30), CENTER_ALLIGN, LAYER_GUI);
+    context.draw_text(gold_text, level->name, Vector(SCREEN_WIDTH/2, 30), CENTER_ALLIGN, LAYER_GUI);
     if(level_nb != -1)
       {
       char str[128];
       sprintf(str, "%i/%i", level_nb+1, level_subset->get_num_levels());
-      context.draw_text(gold_text, str, Vector(screen->w/2, 50), CENTER_ALLIGN, LAYER_GUI);
+      context.draw_text(gold_text, str, Vector(SCREEN_WIDTH/2, 50), CENTER_ALLIGN, LAYER_GUI);
       }
 
     context.pop_transform();
@@ -657,16 +657,16 @@ void LevelEditor::draw(DrawingContext& context)
 
     if(show_grid)
       {
-      for(int x = 0; x < screen->w / (32*zoom); x++)
+      for(int x = 0; x < SCREEN_WIDTH / (32*zoom); x++)
         {
         int pos = (int)(x*32*zoom) - ((int)scroll.x % 32);
-        context.draw_filled_rect(Vector (pos, 0), Vector(1, screen->h),
+        context.draw_filled_rect(Vector (pos, 0), Vector(1, SCREEN_HEIGHT),
                   Color(225, 225, 225), LAYER_GUI-50);
         }
-      for(int y = 0; y < screen->h / (32*zoom); y++)
+      for(int y = 0; y < SCREEN_HEIGHT / (32*zoom); y++)
         {
         int pos = (int)(y*32*zoom) - ((int)scroll.y % 32);
-        context.draw_filled_rect(Vector (0, pos), Vector(screen->w, 1),
+        context.draw_filled_rect(Vector (0, pos), Vector(SCREEN_WIDTH, 1),
                   Color(225, 225, 225), LAYER_GUI-50);
         }
       }
@@ -704,7 +704,7 @@ void LevelEditor::draw(DrawingContext& context)
     context.pop_transform();
     }
   else
-    context.draw_filled_rect(Vector(0,0), Vector(screen->w,screen->h),Color(0,0,0), LAYER_BACKGROUND0);
+    context.draw_filled_rect(Vector(0,0), Vector(SCREEN_WIDTH,SCREEN_HEIGHT),Color(0,0,0), LAYER_BACKGROUND0);
 
   context.do_drawing();
 }
@@ -995,12 +995,12 @@ void LevelEditor::show_help()
     {
     draw(context);
 
-    context.draw_text(blue_text, _("- Level Editor's Help -"), Vector(screen->w/2, 60), CENTER_ALLIGN, LAYER_GUI);
+    context.draw_text(blue_text, _("- Level Editor's Help -"), Vector(SCREEN_WIDTH/2, 60), CENTER_ALLIGN, LAYER_GUI);
 
     context.draw_text(white_small_text, *text[i], Vector(20, 120), LEFT_ALLIGN, LAYER_GUI);
 
     sprintf(str,_("Press any key to continue - Page %d/%d"), i+1, sizeof(text) / sizeof(text[0]));
-    context.draw_text(gold_text, str, Vector(screen->w/2, screen->h-60), CENTER_ALLIGN, LAYER_GUI);
+    context.draw_text(gold_text, str, Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT-60), CENTER_ALLIGN, LAYER_GUI);
 
     context.do_drawing();
 
index 9b32379..9a44e2b 100644 (file)
@@ -49,7 +49,7 @@ void process_options_menu(void)
       if(use_gl != options_menu->isToggled(MNID_OPENGL))
         {
           use_gl = !use_gl;
-          Setup::video(screen->w,screen->h);
+          Setup::video(SCREEN_WIDTH,SCREEN_HEIGHT);
         }
 #else
       options_menu->get_item_by_id(MNID_OPENGL).toggled = false;
@@ -59,7 +59,7 @@ void process_options_menu(void)
       if(use_fullscreen != options_menu->isToggled(MNID_FULLSCREEN))
         {
           use_fullscreen = !use_fullscreen;
-          Setup::video(screen->w,screen->h);
+          Setup::video(SCREEN_WIDTH,SCREEN_HEIGHT);
         }
       break;
     case MNID_SOUND:
@@ -93,7 +93,7 @@ void st_menu(void)
   contrib_subset_menu   = new Menu();
   worldmap_menu  = new Menu();
 
-  main_menu->set_pos(screen->w/2, 335);
+  main_menu->set_pos(SCREEN_WIDTH/2, 335);
   main_menu->additem(MN_GOTO, _("Start Game"),0,load_game_menu, MNID_STARTGAME);
   main_menu->additem(MN_GOTO, _("Contrib Levels"),0,contrib_menu, MNID_LEVELS_CONTRIB);
   main_menu->additem(MN_GOTO, _("Options"),0,options_menu, MNID_OPTIONMENU);
index b03b05f..a8c5edc 100644 (file)
@@ -103,7 +103,7 @@ Background::set_gradient(Color top, Color bottom)
   gradient_bottom = bottom;
 
   delete image;
-  image = new Surface(top, bottom, screen->w, screen->h);
+  image = new Surface(top, bottom, SCREEN_WIDTH, SCREEN_HEIGHT);
 }
 
 void
@@ -122,8 +122,8 @@ Background::draw(DrawingContext& context)
     int sy = int(-context.get_translation().y * speed) % image->h - image->h;
     context.push_transform();
     context.set_translation(Vector(0, 0));
-    for(int x = sx; x < screen->w; x += image->w)
-      for(int y = sy; y < screen->h; y += image->h)
+    for(int x = sx; x < SCREEN_WIDTH; x += image->w)
+      for(int y = sy; y < SCREEN_HEIGHT; y += image->h)
         context.draw_surface(image, Vector(x, y), layer);
     context.pop_transform();
   }
index e80491a..5a7a1d4 100644 (file)
@@ -52,9 +52,9 @@ Bullet::action(float elapsed_time)
   float scroll_y =
     Sector::current()->camera->get_translation().y;
   if (get_pos().x < scroll_x ||
-      get_pos().x > scroll_x + screen->w ||
+      get_pos().x > scroll_x + SCREEN_WIDTH ||
 //     get_pos().y < scroll_y ||
-      get_pos().y > scroll_y + screen->h ||
+      get_pos().y > scroll_y + SCREEN_HEIGHT ||
       life_count <= 0) {
     remove_me();
     return;
index 1b60386..8aa8d42 100644 (file)
@@ -131,8 +131,8 @@ Camera::write(lisp::Writer& writer)
 void
 Camera::reset(const Vector& tuxpos)
 {
-  translation.x = tuxpos.x - screen->w/3 * 2;
-  translation.y = tuxpos.y - screen->h/2;
+  translation.x = tuxpos.x - SCREEN_WIDTH/3 * 2;
+  translation.y = tuxpos.y - SCREEN_HEIGHT/2;
   keep_in_bounds();
 }
 
@@ -155,12 +155,12 @@ Camera::keep_in_bounds()
   float height = sector->solids->get_height() * 32;
 
   // don't scroll before the start or after the level's end
-  if(translation.y > height - screen->h)
-    translation.y = height - screen->h;
+  if(translation.y > height - SCREEN_HEIGHT)
+    translation.y = height - SCREEN_HEIGHT;
   if(translation.y < 0)                                      
     translation.y = 0; 
-  if(translation.x > width - screen->w)
-    translation.x = width - screen->w;
+  if(translation.x > width - SCREEN_WIDTH)
+    translation.x = width - SCREEN_WIDTH;
   if(translation.x < 0)
     translation.x = 0;                                         
 }
@@ -193,7 +193,7 @@ Camera::scroll_normal(float elapsed_time)
       target_y = player->get_bbox().p2.y;
 
     // delta_y is the distance we'd have to travel to directly reach target_y
-    float delta_y = translation.y - (target_y - screen->h/2);
+    float delta_y = translation.y - (target_y - SCREEN_HEIGHT/2);
     // speed is the speed the camera would need to reach target_y in this frame
     float speed_y = delta_y / elapsed_time;
 
@@ -221,19 +221,19 @@ Camera::scroll_normal(float elapsed_time)
       || (player->dir == ::RIGHT && scrollchange == LEFT))
     scrollchange = NONE;
   // when in left 1/3rd of screen scroll left
-  if(player->get_bbox().get_middle().x < translation.x + screen->w/3 - 16
+  if(player->get_bbox().get_middle().x < translation.x + SCREEN_WIDTH/3 - 16
       && do_backscrolling)
     scrollchange = LEFT;
   // scroll right when in right 1/3rd of screen
-  else if(player->get_bbox().get_middle().x > translation.x + screen->w/3*2+16)
+  else if(player->get_bbox().get_middle().x > translation.x + SCREEN_WIDTH/3*2+16)
     scrollchange = RIGHT;
 
   // calculate our scroll target depending on scroll mode
   float target_x;
   if(scrollchange == LEFT)
-    target_x = player->get_bbox().get_middle().x - screen->w/3*2;
+    target_x = player->get_bbox().get_middle().x - SCREEN_WIDTH/3*2;
   else if(scrollchange == RIGHT)
-    target_x = player->get_bbox().get_middle().x - screen->w/3;
+    target_x = player->get_bbox().get_middle().x - SCREEN_WIDTH/3;
   else
     target_x = translation.x;
 
index a6ff565..d4f83ea 100644 (file)
@@ -26,8 +26,8 @@ Fireworks::action(float )
     if(timer.check()) {
         Sector* sector = Sector::current();
         Vector pos = sector->camera->get_translation();
-        pos += Vector(screen->w * ((float) rand() / RAND_MAX),
-                      screen->h/2 * ((float) rand() / RAND_MAX));
+        pos += Vector(SCREEN_WIDTH * ((float) rand() / RAND_MAX),
+                      SCREEN_HEIGHT/2 * ((float) rand() / RAND_MAX));
 
         int red = rand() % 255;
         int green = rand() % red;
index bce0f21..7f1a79f 100644 (file)
@@ -222,8 +222,8 @@ Particles::action(float elapsed_time)
     (*i)->vel.x += accel.x * elapsed_time;
     (*i)->vel.y += accel.y * elapsed_time;
 
-    if((*i)->pos.x < camera.x || (*i)->pos.x > screen->w + camera.x ||
-       (*i)->pos.y < camera.y || (*i)->pos.y > screen->h + camera.y) {
+    if((*i)->pos.x < camera.x || (*i)->pos.x > SCREEN_WIDTH + camera.x ||
+       (*i)->pos.y < camera.y || (*i)->pos.y > SCREEN_HEIGHT + camera.y) {
       delete (*i);
       i = particles.erase(i);
     } else {
index 394fe1d..be1622a 100644 (file)
@@ -32,8 +32,8 @@
 
 ParticleSystem::ParticleSystem()
 {
-    virtual_width = screen->w;
-    virtual_height = screen->h;
+    virtual_width = SCREEN_WIDTH;
+    virtual_height = SCREEN_HEIGHT;
     layer = LAYER_BACKGROUND1;
 }
 
@@ -64,8 +64,8 @@ void ParticleSystem::draw(DrawingContext& context)
         pos.y = fmodf(particle->pos.y - scrolly, virtual_height);
         if(pos.y < 0) pos.y += virtual_height;
 
-        if(pos.x > screen->w) pos.x -= virtual_width;
-        if(pos.y > screen->h) pos.y -= virtual_height;
+        if(pos.x > SCREEN_WIDTH) pos.x -= virtual_width;
+        if(pos.y > SCREEN_HEIGHT) pos.y -= virtual_height;
         context.draw_surface(particle->texture, pos, layer);
     }
 
@@ -78,14 +78,14 @@ SnowParticleSystem::SnowParticleSystem()
     snowimages[1] = new Surface(datadir+"/images/shared/snow1.png", true);
     snowimages[2] = new Surface(datadir+"/images/shared/snow2.png", true);
 
-    virtual_width = screen->w * 2;
+    virtual_width = SCREEN_WIDTH * 2;
 
     // create some random snowflakes
     size_t snowflakecount = size_t(virtual_width/10.0);
     for(size_t i=0; i<snowflakecount; ++i) {
         SnowParticle* particle = new SnowParticle;
         particle->pos.x = rand() % int(virtual_width);
-        particle->pos.y = rand() % screen->h;
+        particle->pos.y = rand() % SCREEN_HEIGHT;
         int snowsize = rand() % 3;
         particle->texture = snowimages[snowsize];
         do {
@@ -123,7 +123,7 @@ void SnowParticleSystem::action(float elapsed_time)
     for(i = particles.begin(); i != particles.end(); ++i) {
         SnowParticle* particle = (SnowParticle*) *i;
         particle->pos.y += particle->speed * elapsed_time;
-        if(particle->pos.y > screen->h) {
+        if(particle->pos.y > SCREEN_HEIGHT) {
             particle->pos.y = fmodf(particle->pos.y , virtual_height);
             particle->pos.x = rand() % int(virtual_width);
         }
@@ -135,14 +135,14 @@ RainParticleSystem::RainParticleSystem()
     rainimages[0] = new Surface(datadir+"/images/shared/rain0.png", true);
     rainimages[1] = new Surface(datadir+"/images/shared/rain1.png", true);
 
-    virtual_width = screen->w * 2;
+    virtual_width = SCREEN_WIDTH * 2;
 
     // create some random raindrops
     size_t raindropcount = size_t(virtual_width/8.0);
     for(size_t i=0; i<raindropcount; ++i) {
         RainParticle* particle = new RainParticle;
         particle->pos.x = rand() % int(virtual_width);
-        particle->pos.y = rand() % screen->h;
+        particle->pos.y = rand() % SCREEN_HEIGHT;
         int rainsize = rand() % 2;
         particle->texture = rainimages[rainsize];
         do {
@@ -181,7 +181,7 @@ void RainParticleSystem::action(float elapsed_time)
         RainParticle* particle = (RainParticle*) *i;
         particle->pos.y += particle->speed * elapsed_time;
         particle->pos.x -= particle->speed * elapsed_time;
-        if(particle->pos.y > screen->h) {
+        if(particle->pos.y > SCREEN_HEIGHT) {
             particle->pos.y = fmodf(particle->pos.y , virtual_height);
             particle->pos.x = rand() % int(virtual_width);
         }
index 0fcc752..92cd588 100644 (file)
@@ -974,10 +974,10 @@ Player::check_bounds(Camera* camera)
     bbox.set_pos(Vector(camera->get_translation().x, get_pos().y));
     adjust = true;
   }
-  if(get_pos().x >= camera->get_translation().x + screen->w - bbox.get_width())
+  if(get_pos().x >= camera->get_translation().x + SCREEN_WIDTH - bbox.get_width())
   {
     bbox.set_pos(Vector(
-          camera->get_translation().x + screen->w - bbox.get_width(),
+          camera->get_translation().x + SCREEN_WIDTH - bbox.get_width(),
           get_pos().y));
     adjust = true;
   }
index 578bb51..7fad234 100644 (file)
@@ -152,8 +152,8 @@ TileMap::draw(DrawingContext& context)
   if(start_x < 0) start_x = 0;
   float start_y = roundf(context.get_translation().y);
   if(start_y < 0) start_y = 0;
-  float end_x = std::min(start_x + screen->w, float(width * 32));
-  float end_y = std::min(start_y + screen->h, float(height * 32));
+  float end_x = std::min(start_x + SCREEN_WIDTH, float(width * 32));
+  float end_y = std::min(start_y + SCREEN_HEIGHT, float(height * 32));
   start_x -= int(start_x) % 32;
   start_y -= int(start_y) % 32;  
   int tsx = int(start_x / 32); // tilestartindex x
index dc3e83a..2ea2e49 100644 (file)
@@ -161,12 +161,12 @@ Statistics::draw_message_info(DrawingContext& context, std::string title)
   if(stats[SCORE_STAT][SPLAYER] == -1)  // not initialized yet
     return;
 
-  context.draw_text(gold_text, title, Vector(screen->w/2, 410), CENTER_ALLIGN, LAYER_GUI);
+  context.draw_text(gold_text, title, Vector(SCREEN_WIDTH/2, 410), CENTER_ALLIGN, LAYER_GUI);
 
   char str[128];
 
   sprintf(str, _(    "Max score:             %d"), stats[SCORE_STAT][SPLAYER]);
-  context.draw_text(white_text, str, Vector(screen->w/2, 450), CENTER_ALLIGN, LAYER_GUI);
+  context.draw_text(white_text, str, Vector(SCREEN_WIDTH/2, 450), CENTER_ALLIGN, LAYER_GUI);
 
   for(int i = 1; i < NUM_STATS; i++)
     {
@@ -184,7 +184,7 @@ Statistics::draw_message_info(DrawingContext& context, std::string title)
               stats[TIME_NEEDED_STAT][STOTAL]);
 
 
-    context.draw_text(white_small_text, str, Vector(screen->w/2, 462 + i*18), CENTER_ALLIGN, LAYER_GUI);
+    context.draw_text(white_small_text, str, Vector(SCREEN_WIDTH/2, 462 + i*18), CENTER_ALLIGN, LAYER_GUI);
     }
 }
 
index 06cbbe7..46efc59 100644 (file)
@@ -51,7 +51,7 @@ int main(int argc, char * argv[])
     Setup::parseargs(argc, argv);
 
     Setup::audio();
-    Setup::video(800, 600);
+    Setup::video(screen_width, screen_height);
     Setup::joystick();
     Setup::general();
     st_menu();
index 9038ede..1b911b1 100644 (file)
@@ -153,12 +153,12 @@ void display_text_file(const std::string& file)
         if(center) {
           context.draw_text(font,
               line.substr(1, line.size()-1),
-              Vector(screen->w/2, screen->h + y - scroll),
+              Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT + y - scroll),
               CENTER_ALLIGN, LAYER_FOREGROUND1);
         } else {
           context.draw_text(font,
               line.substr(1, line.size()-1),
-              Vector(left_border, screen->h + y - scroll),
+              Vector(left_border, SCREEN_HEIGHT + y - scroll),
               LEFT_ALLIGN, LAYER_FOREGROUND1);
         }
           
@@ -167,7 +167,7 @@ void display_text_file(const std::string& file)
 
       context.do_drawing();
 
-      if(screen->h+y-scroll < 0 && 20+screen->h+y-scroll < 0)
+      if(SCREEN_HEIGHT+y-scroll < 0 && 20+SCREEN_HEIGHT+y-scroll < 0)
         done = 1;
 
       Uint32 ticks = SDL_GetTicks();
@@ -239,7 +239,7 @@ InfoBox::draw(DrawingContext& context)
     if(center) {
       context.draw_text(font,
           line.substr(1, line.size()-1),
-          Vector(screen->w/2, y),
+          Vector(SCREEN_WIDTH/2, y),
           CENTER_ALLIGN, LAYER_GUI);
     } else {
       context.draw_text(font,
index a60181c..59df3d0 100644 (file)
@@ -181,7 +181,7 @@ void check_levels_contrib_menu()
     fadeout(256);
     DrawingContext context;
     context.draw_text(white_text, "Loading...",
-        Vector(screen->w/2, screen->h/2), CENTER_ALLIGN, LAYER_FOREGROUND1);
+        Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT/2), CENTER_ALLIGN, LAYER_FOREGROUND1);
     context.do_drawing();
 
     // TODO: slots should be available for contrib maps
@@ -341,18 +341,18 @@ void title(void)
       
       
       if (Menu::current() == main_menu)
-        context.draw_surface(logo, Vector(screen->w/2 - logo->w/2, 30),
+        context.draw_surface(logo, Vector(SCREEN_WIDTH/2 - logo->w/2, 30),
             LAYER_FOREGROUND1+1);
 
       context.draw_text(white_small_text, " SuperTux " PACKAGE_VERSION "\n",
-              Vector(0, screen->h - 50), LEFT_ALLIGN, LAYER_FOREGROUND1);
+              Vector(0, SCREEN_HEIGHT - 50), LEFT_ALLIGN, LAYER_FOREGROUND1);
       context.draw_text(white_small_text,
         _(
 "Copyright (c) 2003 SuperTux Devel Team\n"
 "This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to\n"
 "redistribute it under certain conditions; see the file COPYING for details.\n"
         ),
-        Vector(0, screen->h - 50 + white_small_text->get_height() + 5),
+        Vector(0, SCREEN_HEIGHT - 50 + white_small_text->get_height() + 5),
         LEFT_ALLIGN, LAYER_FOREGROUND1);
 
       /* Don't draw menu, if quit is true */
index b49ecaa..3752292 100644 (file)
@@ -793,11 +793,11 @@ WorldMap::update(float delta)
                   LAYER_BACKGROUND0);
 
               context.draw_text(blue_text, _("GAMEOVER"), 
-                  Vector(screen->w/2, 200), CENTER_ALLIGN, LAYER_FOREGROUND1);
+                  Vector(SCREEN_WIDTH/2, 200), CENTER_ALLIGN, LAYER_FOREGROUND1);
 
               sprintf(str, _("COINS: %d"), player_status.distros);
               context.draw_text(gold_text, str,
-                  Vector(screen->w/2, screen->w - 32), CENTER_ALLIGN,
+                  Vector(SCREEN_WIDTH/2, SCREEN_WIDTH - 32), CENTER_ALLIGN,
                   LAYER_FOREGROUND1);
 
               total_stats.draw_message_info(context, _("Total Statistics"));
@@ -957,29 +957,29 @@ WorldMap::draw_status(DrawingContext& context)
   context.draw_text(gold_text, str, Vector(96, 0), LEFT_ALLIGN, LAYER_FOREGROUND1);
 
   sprintf(str, "%d", player_status.distros);
-  context.draw_text(white_text, _("COINS"), Vector(screen->w/2 - 16*5, 0),
+  context.draw_text(white_text, _("COINS"), Vector(SCREEN_WIDTH/2 - 16*5, 0),
       LEFT_ALLIGN, LAYER_FOREGROUND1);
-  context.draw_text(gold_text, str, Vector(screen->w/2 + (16*5)/2, 0),
+  context.draw_text(gold_text, str, Vector(SCREEN_WIDTH/2 + (16*5)/2, 0),
         LEFT_ALLIGN, LAYER_FOREGROUND1);
 
   if (player_status.lives >= 5)
     {
       sprintf(str, "%dx", player_status.lives);
       context.draw_text(gold_text, str, 
-          Vector(screen->w - gold_text->get_text_width(str) - tux_life->w, 0),
+          Vector(SCREEN_WIDTH - gold_text->get_text_width(str) - tux_life->w, 0),
           LEFT_ALLIGN, LAYER_FOREGROUND1);
-      context.draw_surface(tux_life, Vector(screen->w -
+      context.draw_surface(tux_life, Vector(SCREEN_WIDTH -
             gold_text->get_text_width("9"), 0), LEFT_ALLIGN, LAYER_FOREGROUND1);
     }
   else
     {
       for(int i= 0; i < player_status.lives; ++i)
         context.draw_surface(tux_life,
-            Vector(screen->w - tux_life->w*4 + (tux_life->w*i), 0),
+            Vector(SCREEN_WIDTH - tux_life->w*4 + (tux_life->w*i), 0),
             LAYER_FOREGROUND1);
     }
   context.draw_text(white_text, _("LIVES"),
-      Vector(screen->w - white_text->get_text_width(_("LIVES")) - white_text->get_text_width("   99"), 0),
+      Vector(SCREEN_WIDTH - white_text->get_text_width(_("LIVES")) - white_text->get_text_width("   99"), 0),
       LEFT_ALLIGN, LAYER_FOREGROUND1);
 
   if (!tux->is_moving())
@@ -992,8 +992,8 @@ WorldMap::draw_status(DrawingContext& context)
                 get_level_title(*i);
 
               context.draw_text(white_text, i->title, 
-                  Vector(screen->w/2,
-                         screen->h - white_text->get_height() - 30),
+                  Vector(SCREEN_WIDTH/2,
+                         SCREEN_HEIGHT - white_text->get_height() - 30),
                   CENTER_ALLIGN, LAYER_FOREGROUND1);
 
               i->statistics.draw_worldmap_info(context);
@@ -1007,8 +1007,8 @@ WorldMap::draw_status(DrawingContext& context)
                /* Display an in-map message in the map, if any as been selected */
               if(!i->map_message.empty() && !i->passive_message)
                 context.draw_text(gold_text, i->map_message, 
-                    Vector(screen->w/2,
-                           screen->h - white_text->get_height() - 60),
+                    Vector(SCREEN_WIDTH/2,
+                           SCREEN_HEIGHT - white_text->get_height() - 60),
                     CENTER_ALLIGN, LAYER_FOREGROUND1);
               break;
             }
@@ -1017,7 +1017,7 @@ WorldMap::draw_status(DrawingContext& context)
   /* Display a passive message in the map, if needed */
   if(passive_message_timer.check())
     context.draw_text(gold_text, passive_message, 
-            Vector(screen->w/2, screen->h - white_text->get_height() - 60),
+            Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT - white_text->get_height() - 60),
             CENTER_ALLIGN, LAYER_FOREGROUND1);
 
   context.pop_transform();
@@ -1053,14 +1053,14 @@ WorldMap::display()
     
     Vector tux_pos = tux->get_pos();
     
-    offset.x = -tux_pos.x + screen->w/2;
-    offset.y = -tux_pos.y + screen->h/2;
+    offset.x = -tux_pos.x + SCREEN_WIDTH/2;
+    offset.y = -tux_pos.y + SCREEN_HEIGHT/2;
 
     if (offset.x > 0) offset.x = 0;
     if (offset.y > 0) offset.y = 0;
 
-    if (offset.x < screen->w - width*32) offset.x = screen->w - width*32;
-    if (offset.y < screen->h - height*32) offset.y = screen->h - height*32;
+    if (offset.x < SCREEN_WIDTH - width*32) offset.x = SCREEN_WIDTH - width*32;
+    if (offset.y < SCREEN_HEIGHT - height*32) offset.y = SCREEN_HEIGHT - height*32;
   
     context.push_transform();
     context.set_translation(-offset);