pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r3891 - trunk/pingus/src


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3891 - trunk/pingus/src
Date: Mon, 21 Jul 2008 20:45:15 +0200

Author: grumbel
Date: 2008-07-21 20:45:14 +0200 (Mon, 21 Jul 2008)
New Revision: 3891

Modified:
   trunk/pingus/src/ground_map.cpp
Log:
defer Sprite update till its actually requested, should improve load times a bit

Modified: trunk/pingus/src/ground_map.cpp
===================================================================
--- trunk/pingus/src/ground_map.cpp     2008-07-21 18:33:09 UTC (rev 3890)
+++ trunk/pingus/src/ground_map.cpp     2008-07-21 18:45:14 UTC (rev 3891)
@@ -31,7 +31,8 @@
 private:
   Sprite   sprite;
   Surface  surface;
-
+  bool sprite_needs_update;
+  
 public:
   MapTile();
   ~MapTile();
@@ -39,10 +40,11 @@
   void remove(Surface, int x, int y, int real_x, int real_y, GroundMap*);  
   void put(Surface, int x, int y);  
 
-  Sprite get_sprite() const { return sprite; }
+  Sprite get_sprite();
 };
 
 MapTile::MapTile () 
+  : sprite_needs_update(false)
 {
 }
 
@@ -54,10 +56,10 @@
 MapTile::remove(Surface src, int x, int y, 
                 int real_x, int real_y, GroundMap* parent)
 {
-  if (sprite)
+  if (surface)
     {
       parent->put_alpha_surface(surface, src, x, y, real_x, real_y);
-      sprite = Sprite(surface);
+      sprite_needs_update = true;
     }
 }
 
@@ -66,10 +68,24 @@
 {
   if (!surface)
     surface = Surface(tile_size, tile_size);
-
+  
   surface.blit(src, x, y);
-  sprite = Sprite(surface);
+  sprite_needs_update = true;
 }
+
+Sprite 
+MapTile::get_sprite() 
+{
+  if (sprite_needs_update)
+    {
+      sprite_needs_update = false;
+      return sprite = Sprite(surface);
+    }
+  else
+    {
+      return sprite; 
+    }
+}
 
 GroundMap::GroundMap(int width_, int height_)
   : width(width_), height(height_)





reply via email to

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