}
/* 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;
}
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 */
}
// 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