From d25d6cea43694b0d74ab7b5e30298ef172f0a159 Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Sat, 15 May 2004 09:59:02 +0000 Subject: [PATCH] Cleanup. Also applied the same fix to leveleditor. Unfortanely, still crashes, aparentelly in the same point. SVN-Revision: 1184 --- src/leveleditor.cpp | 8 ++++---- src/world.cpp | 14 ++++---------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index 44c01e99d..ccb9b4b88 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -1579,15 +1579,15 @@ void le_checkevents() } /* checking if pos_x and pos_y is within the limits... */ - if(pos_x < 0) - pos_x = 0; if(pos_x > (le_world->get_level()->width * 32) - screen->w) pos_x = (le_world->get_level()->width * 32) - screen->w; + if(pos_x < 0) + pos_x = 0; - if(pos_y < 0) - pos_y = 0; if(pos_y > (le_world->get_level()->height * 32) - screen->h) pos_y = (le_world->get_level()->height * 32) - screen->h; + if(pos_y < 0) + pos_y = 0; } diff --git a/src/world.cpp b/src/world.cpp index a62ecd3d9..323f628f1 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -327,16 +327,10 @@ void World::scrolling(double frame_ratio) scroll_y = tux_pos_y - Y_SPACE; // this code prevent the screen to scroll before the start or after the level's end - if(scroll_y < 0) - scroll_y = 0; - else if(scroll_y > level->height * 32 - screen->h) + if(scroll_y > level->height * 32 - screen->h) scroll_y = level->height * 32 - screen->h; - - if (scroll_y < 0) - { - //std::cerr << "Level too short!!" << std::endl; + if(scroll_y < 0) scroll_y = 0; - } /* X-axis scrolling */ @@ -389,10 +383,10 @@ void World::scrolling(double frame_ratio) } // this code prevent the screen to scroll before the start or after the level's end + if(scroll_x > level->width * 32 - screen->w) + scroll_x = level->width * 32 - screen->w; if(scroll_x < 0) scroll_x = 0; - else if(scroll_x > level->width * 32 - screen->w) - scroll_x = level->width * 32 - screen->w; } void -- 2.11.0