fixed background drawing problems introduced with my last commit
authorMatthias Braun <matze@braunis.de>
Fri, 26 Nov 2004 14:54:05 +0000 (14:54 +0000)
committerMatthias Braun <matze@braunis.de>
Fri, 26 Nov 2004 14:54:05 +0000 (14:54 +0000)
SVN-Revision: 2203

lib/special/collision.cpp
src/gameloop.cpp
src/sector.cpp
src/sector.h

index 889899f..46ed0bf 100644 (file)
@@ -146,7 +146,6 @@ Collision::rectangle_aatriangle(CollisionHit& hit, const Rectangle& rect,
     return false;
   float time = depth / -(normal * movement);
   if(time < hit.time) {
-    printf("Time: %f.\n", time);
     hit.depth = depth;
     hit.time = time;
     hit.normal = normal;
index a5933de..1b2914b 100644 (file)
@@ -185,8 +185,13 @@ GameSession::levelintro(void)
   char str[60];
 
   DrawingContext context;
-  if(currentsector->background)
-    currentsector->background->draw(context);
+  for(Sector::GameObjects::iterator i = currentsector->gameobjects.begin();
+      i != currentsector->gameobjects.end(); ++i) {
+    Background* background = dynamic_cast<Background*> (*i);
+    if(background) {
+      background->draw(context);
+    }
+  }
 
 //  context.draw_text(gold_text, level->get_name(), Vector(screen->w/2, 160),
 //      CENTER_ALLIGN, LAYER_FOREGROUND1);
@@ -905,12 +910,18 @@ GameSession::drawstatus(DrawingContext& context)
 }
 
 void
-GameSession::drawresultscreen(void)
+GameSession::drawresultscreen()
 {
   char str[80];
 
   DrawingContext context;
-  currentsector->background->draw(context);  
+  for(Sector::GameObjects::iterator i = currentsector->gameobjects.begin();
+      i != currentsector->gameobjects.end(); ++i) {
+    Background* background = dynamic_cast<Background*> (*i);
+    if(background) {
+      background->draw(context);
+    }
+  }
 
   context.draw_text(blue_text, _("Result:"), Vector(screen->w/2, 200),
       CENTER_ALLIGN, LAYER_FOREGROUND1);
index 9873100..f9b5ede 100644 (file)
@@ -63,7 +63,7 @@
 Sector* Sector::_current = 0;
 
 Sector::Sector()
-  : gravity(10), player(0), solids(0), background(0), camera(0),
+  : gravity(10), player(0), solids(0), camera(0),
     currentmusic(LEVEL_MUSIC)
 {
   song_title = "Mortimers_chipdisko.mod";
@@ -93,8 +93,7 @@ GameObject*
 Sector::parse_object(const std::string& name, LispReader& reader)
 {
   if(name == "background") {
-    background = new Background(reader);
-    return background;
+    return new Background(reader);
   } else if(name == "camera") {
     Camera* camera = new Camera(this);
     camera->parse(reader);
index a30e5d4..45a2cd5 100644 (file)
@@ -134,7 +134,6 @@ public:
   // some special objects, where we need direct access
   Player* player;
   TileMap* solids;
-  Background* background;
   Camera* camera;
   
 private: