pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r2661 - branches/pingus_sdl/src


From: grumbel at BerliOS
Subject: [Pingus-CVS] r2661 - branches/pingus_sdl/src
Date: Tue, 16 Jan 2007 00:28:23 +0100

Author: grumbel
Date: 2007-01-16 00:28:22 +0100 (Tue, 16 Jan 2007)
New Revision: 2661

Modified:
   branches/pingus_sdl/src/sprite.cpp
Log:
- origin calculation fixed

Modified: branches/pingus_sdl/src/sprite.cpp
===================================================================
--- branches/pingus_sdl/src/sprite.cpp  2007-01-15 22:11:33 UTC (rev 2660)
+++ branches/pingus_sdl/src/sprite.cpp  2007-01-15 23:28:22 UTC (rev 2661)
@@ -42,43 +42,37 @@
 
   SpriteImpl(const SpriteDescription& desc)
   {
-    surface = IMG_Load(desc.filename.c_str());
-    if (!surface)
-      {
-        std::cout << "Error: Couldn't load " << desc.filename << std::endl;
-        surface = IMG_Load("data/images/core/misc/404.png");
-        assert(surface);
-      }
-    else
-      {
-        std::cout << "Loaded sprite: " << desc.filename << std::endl;
-      }
-
-    
     origin = desc.origin;
-    offset = calc_origin(origin, Size(surface->w, surface->h)) + desc.offset;
-
-    std::cout << "offset: " << offset.x << ", " << offset.y << std::endl;
+    offset = desc.offset;
+    load(desc.filename);
   }
 
   SpriteImpl(const std::string& name) 
   {
     std::ostringstream str;
     str << "data/images/" << name << ".png";
-    surface = IMG_Load(str.str().c_str());
+
+    load(str.str());
+  }
+
+  void 
+  load(const std::string& filename)
+  {
+    surface = IMG_Load(filename.c_str());
     if (!surface)
       {
-        std::cout << "Error: Couldn't load " << str.str() << std::endl;
+        std::cout << "Error: Couldn't load " << filename << std::endl;
         surface = IMG_Load("data/images/core/misc/404.png");
         assert(surface);
       }
     else
       {
-        std::cout << "Loaded sprite: " << name << std::endl;
+        std::cout << "Loaded sprite: " << filename << std::endl;
       }
+    
+    offset = calc_origin(origin, Size(surface->w, surface->h)) + offset;
 
-    //offset.x = surface->w/2;
-    //offset.y = surface->h/2;
+    std::cout << "offset: " << offset.x << ", " << offset.y << std::endl;
   }
 
   ~SpriteImpl()
@@ -91,7 +85,7 @@
     SDL_Rect pos;
     
     pos.x = (Sint16)(x - offset.x);
-    pos.y = (Sint16)(y + offset.y);
+    pos.y = (Sint16)(y - offset.y);
     pos.w = 0;
     pos.h = 0;
     





reply via email to

[Prev in Thread] Current Thread [Next in Thread]