BouncyDistro::draw()
{
img_distro[0]->draw(base.x - scroll_x,
- base.y);
+ base.y - scroll_y);
}
src.h = 16;
dest.x = (int)(base.x - scroll_x);
- dest.y = (int)base.y;
+ dest.y = (int)(base.y - scroll_y);
dest.w = 16;
dest.h = 16;
base.x <= scroll_x + screen->w)
{
dest.x = (int)(base.x - scroll_x);
- dest.y = (int)base.y;
+ dest.y = (int)(base.y - scroll_y);
dest.w = 32;
dest.h = 32;
// paint it later at on offseted position
if(plevel->bkgd_image[0] == '\0')
{
- fillrect(base.x - scroll_x, base.y,
+ fillrect(base.x - scroll_x, base.y - scroll_y,
32,32,
plevel->bkgd_top.red, plevel->bkgd_top.green, plevel->bkgd_top.blue, 0);
// FIXME: doesn't respect the gradient, futhermore is this necessary at all??
}
Tile::draw(base.x - scroll_x,
- base.y + offset,
+ base.y - scroll_y + offset,
shape);
}
}
}
// FIXME: Move this into a view class
-float scroll_x;
+float scroll_x, scroll_y;
unsigned int global_frame_counter;
extern PlayerStatus player_status;
-extern float scroll_x;
+extern float scroll_x, scroll_y;
extern unsigned int global_frame_counter;
#endif /*SUPERTUX_SCENE_H*/
unsigned int frame = get_current_frame();
if (frame < surfaces.size())
- surfaces[frame]->draw(x - x_hotspot, y - y_hotspot);
+ surfaces[frame]->draw(x - x_hotspot, y - y_hotspot - scroll_y);
}
void
for (x = 0; x < 21; ++x)
{
Tile::draw(32*x - fmodf(scroll_x, 32), y * 32,
- level->bg_tiles[(int)y][(int)x + (int)(scroll_x / 32)]);
+ level->bg_tiles[(int)y + (int)(scroll_y / 32)][(int)x + (int)(scroll_x / 32)]);
}
}
for (x = 0; x < 21; ++x)
{
Tile::draw(32*x - fmodf(scroll_x, 32), y * 32,
- level->ia_tiles[(int)y][(int)x + (int)(scroll_x / 32)]);
+ level->ia_tiles[(int)y + (int)(scroll_y / 32)][(int)x + (int)(scroll_x / 32)]);
}
}
for (x = 0; x < 21; ++x)
{
Tile::draw(32*x - fmodf(scroll_x, 32), y * 32,
- level->fg_tiles[(int)y][(int)x + (int)(scroll_x / 32)]);
+ level->fg_tiles[(int)y + (int)(scroll_y / 32)][(int)x + (int)(scroll_x / 32)]);
}
}
scroll_x = 0;
if(scroll_x > level->width * 32 - screen->w)
scroll_x = level->width * 32 - screen->w;
+
+ /* Y-axis scrolling */
+
+ int tux_pos_y = (int)(tux.base.y + (tux.base.height/2));
+
+ scroll_y = tux_pos_y - (screen->h / 2);
+
+ // 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)
+ scroll_y = level->height * 32 - screen->h;
}
void