Allegro and Scrolling

Started by
0 comments, last by clt 14 years, 9 months ago
How exactly would one go about implementing parallax scrolling in Allegro? I have created the layers, marked part of the bitmap with magenta that I want to be masked through, and blitted to the screen - in that order; Nothing works; or more than likely, I am doing something wrong. I can figure the Allegro code out myself - I just need an algorithm.
Advertisement
'Nothing works' is pretty vague, but parallax scrolling works by adjusting the speed at which objects seem to move, based on their perceived distance from the screen. I assume that you've already got a 'camera' system worked out if you're expecting to see any kind of a parallax effect, so all you need to do for parallax layers is to offset them by some fraction of the camera movement.

Assuming that layer 1 is the foremost layer, with higher numbered layers extending outward:
  int x = sprite.x + (cam.x / sprite.layer),      y = sprite.y + (cam.y / sprite.layer);  draw_sprite(buffer, sprite.currentFrame, x, y);

This topic is closed to new replies.

Advertisement