From ca1a2240a54333b9eec99714c89b6b78eeed949c Mon Sep 17 00:00:00 2001 From: Ryan Flegel Date: Fri, 14 May 2004 17:35:30 +0000 Subject: [PATCH] - fixed drawing crash - not quite in a playable state yet :) SVN-Revision: 1179 --- src/tile.cpp | 2 -- src/world.cpp | 17 ++++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/tile.cpp b/src/tile.cpp index 06f684823..116f18529 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -185,8 +185,6 @@ void TileManager::load_tileset(std::string filename) void Tile::draw(float x, float y, unsigned int c, Uint8 alpha) { -fprintf(stderr, "x: %i\n", x); -fprintf(stderr, "y: %i\n", y); if (c != 0) { Tile* ptile = TileManager::instance()->get(c); diff --git a/src/world.cpp b/src/world.cpp index f251e3d74..803f1848f 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -196,16 +196,11 @@ World::draw() (*p)->draw(scroll_x, 0, 0); } -fprintf(stderr, "level->height: %i\n", level->height); -fprintf(stderr, "scroll_x: %i\n", scroll_x); -fprintf(stderr, "scroll_y: %i\n", scroll_y); /* Draw background: */ for (y = 0; y < VISIBLE_TILES_Y && y < level->height; ++y) { -fprintf(stderr, "drawing row: %i\n", y); for (x = 0; x < VISIBLE_TILES_X; ++x) { -fprintf(stderr, "x: %i\n", x); Tile::draw(32*x - fmodf(scroll_x, 32), y * 32 - fmodf(scroll_y, 32), level->bg_tiles[(int)y + (int)(scroll_y / 32)][(int)x + (int)(scroll_x / 32)]); } @@ -340,9 +335,15 @@ void World::scrolling(double frame_ratio) // this code prevent the screen to scroll before the start or after the level's end if(scroll_y < 0) scroll_y = 0; - if(scroll_y > level->height * 32 - screen->h) + else 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; + scroll_y = 0; + } + /* X-axis scrolling */ /* Auto scrolling */ @@ -384,8 +385,6 @@ void World::scrolling(double frame_ratio) scroll_x += (final_scroll_x - scroll_x) / (frame_ratio * (CHANGE_DIR_SCROLL_SPEED / 100)) + (tux.physic.get_velocity_x() * frame_ratio + tux.physic.get_acceleration_x() * frame_ratio * frame_ratio); - // std::cerr << tux_pos_x << " " << final_scroll_x << " " << scroll_x << std::endl; - } else { @@ -398,7 +397,7 @@ 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 < 0) scroll_x = 0; - if(scroll_x > level->width * 32 - screen->w) + else if(scroll_x > level->width * 32 - screen->w) scroll_x = level->width * 32 - screen->w; } -- 2.11.0