From 02d54bd21d3d72e46ecad8f6038666b0384d4eb8 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 26 Nov 2004 14:54:05 +0000 Subject: [PATCH] fixed background drawing problems introduced with my last commit SVN-Revision: 2203 --- lib/special/collision.cpp | 1 - src/gameloop.cpp | 19 +++++++++++++++---- src/sector.cpp | 5 ++--- src/sector.h | 1 - 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/special/collision.cpp b/lib/special/collision.cpp index 889899f76..46ed0bf79 100644 --- a/lib/special/collision.cpp +++ b/lib/special/collision.cpp @@ -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; diff --git a/src/gameloop.cpp b/src/gameloop.cpp index a5933de17..1b2914bef 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -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 (*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 (*i); + if(background) { + background->draw(context); + } + } context.draw_text(blue_text, _("Result:"), Vector(screen->w/2, 200), CENTER_ALLIGN, LAYER_FOREGROUND1); diff --git a/src/sector.cpp b/src/sector.cpp index 98731009a..f9b5ede9c 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -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); diff --git a/src/sector.h b/src/sector.h index a30e5d41d..45a2cd539 100644 --- a/src/sector.h +++ b/src/sector.h @@ -134,7 +134,6 @@ public: // some special objects, where we need direct access Player* player; TileMap* solids; - Background* background; Camera* camera; private: -- 2.11.0