It is only enabled if the level explicity asks for.
SVN-Revision: 939
start_pos_y = 170;
time_left = 100;
gravity = 10.;
+ back_scrolling = false;
bkgd_top.red = 0;
bkgd_top.green = 0;
bkgd_top.blue = 0;
if(!reader.read_int("time", &time_left)) {
printf("Warning no time specified for level.\n");
}
+
+ back_scrolling = false;
+ reader.read_bool("back_scrolling", &back_scrolling);
bkgd_top.red = bkgd_top.green = bkgd_top.blue = 0;
reader.read_int("bkgd_red_top", &bkgd_top.red);
fprintf(fi," (bkgd_blue_bottom %d)\n", bkgd_bottom.blue);
fprintf(fi," (time %d)\n", time_left);
fprintf(fi," (width %d)\n", width);
+ if(back_scrolling)
+ fprintf(fi," (back_scrolling 1)\n");
+ else
+ fprintf(fi," (back_scrolling 0)\n");
fprintf(fi," (gravity %2.1f)\n", gravity);
fprintf(fi," (background-tm ");
int start_pos_x;
int start_pos_y;
float gravity;
+ bool back_scrolling;
std::vector<BadGuyData> badguy_data;
base.x += frame_ratio * WALK_SPEED * (dir ? 1 : -1);
previous_base = old_base = base;
}
- keep_in_bounds();
+ check_bounds();
// Land:
if (!on_ground())
}
void
-Player::keep_in_bounds()
+Player::check_bounds()
{
- Level* plevel = World::current()->get_level();
-
/* Keep tux in bounds: */
if (base.x < 0)
{ // Lock Tux to the size of the level, so that he doesn't fall of
// on the left side
base.x = 0;
}
- else if (base.x < scroll_x)
- {
- base.x = scroll_x;
- }
/* Keep in-bounds, vertically: */
if (base.y > screen->h)
kill(KILL);
}
- int scroll_threshold = screen->w/2 - 80;
- if (debug_mode)
- {
- scroll_x += screen->w/2;
- // Backscrolling for debug mode
- if (scroll_x < base.x - 80)
- scroll_x = base.x - 80;
- else if (scroll_x > base.x + 80)
- scroll_x = base.x + 80;
- scroll_x -= screen->w/2;
-
- if(scroll_x < 0)
- scroll_x = 0;
- }
- else
- {
- if (base.x > scroll_threshold + scroll_x
- && scroll_x < ((World::current()->get_level()->width * 32) - screen->w))
- {
- // FIXME: Scrolling needs to be handled by a seperate View
- // class, doing it as a player huck is ugly
-
- // Scroll the screen in past center:
- scroll_x = base.x - scroll_threshold;
-
- // Lock the scrolling to the levelsize, so that we don't
- // scroll over the right border
- if (scroll_x > 32 * plevel->width - screen->w)
- scroll_x = 32 * plevel->width - screen->w;
- }
- }
+ if(base.x < scroll_x) // can happen if back scrolling is disabled
+ base.x = scroll_x;
}
// EOF //
void is_dying();
bool is_dead();
void player_remove_powerups();
- void keep_in_bounds();
+ void check_bounds();
bool on_ground();
bool under_solid();
void grow();
World::action(double frame_ratio)
{
tux.action(frame_ratio);
+ keep_in_bounds();
/* Handle bouncy distros: */
for (unsigned int i = 0; i < bouncy_distros.size(); i++)
}
}
+// the space that it takes for the screen to start scrolling
+#define X_SPACE 80
+
+/* This functions takes cares of the scrolling */
+void World::keep_in_bounds()
+{
+int tux_pos_x = (int)(tux.base.x - (tux.base.width/2));
+
+scroll_x += screen->w/2;
+
+if (scroll_x < tux_pos_x - X_SPACE)
+ scroll_x = tux_pos_x - X_SPACE;
+else if (scroll_x > tux_pos_x + X_SPACE && level->back_scrolling)
+ scroll_x = tux_pos_x + X_SPACE;
+
+scroll_x -= screen->w/2;
+
+if(scroll_x < 0)
+ scroll_x = 0;
+}
+
+
void
World::collision_handler()
{
void draw();
void action(double frame_ratio);
+ void keep_in_bounds();
void play_music(int musictype);
int get_music_type();