Archived

This topic is now archived and is closed to further replies.

Neen10do

double axis scrolling?

Recommended Posts

Neen10do    122
hey guys, i want my background to be able to scroll on both the x and the y axis. i got it to work on the x axis alone... with a repeating background. i want to be able to do this with the y axis at the same time (diagonal). but this is the problem. if i was just using horizontal scrolling, all i had to do was this image: ------------------- |_________________| |_1_____________2_| |_________________| |_________________| |------------------ scrolling: ------------------- |______|___________| |____2_|__1________| |______|___________| |______|___________| |------------------ this causes a soup can effect (if you know what i mean. but lets say the image was like this: ------------------- |_1_____________2_ |_________________ |_________________| |_3_____________4_| |------------------ so possible scrolling situation could look like this: ------------------- |_____|____________| |____4|3___________| |-----|------------| |____2|1___________| |------------------ this shows how the corners could meet in the middle of the screen. any ideas on how to do this? note:: the solid horizontal lines are just to keep the box from collapsing.... the dotted lines are the picture divisions. ---------------------- i code therefore i am. Aero DX - Coming to a bored Monitor near you! [edited by - Neen10do on March 6, 2003 10:17:25 PM]

Share this post


Link to post
Share on other sites
billybob    134
if the background is the size of the screen, blit it 4 times, and keep the 4 corners meeting place on the screen, like if you keep track of the background position by the coordinates of the bottom right background, just wrap the values if they go off the screen.

if(x > SCREEN_WIDTH) x = 0;
if(y > SCREEN_HEIGHT) y = 0;
if(x < 0) x = SCREEN_WIDTH;
if(y < 0) y = SCREEN_HEIGHT;


(it might work better if those are <= and >= signs, you'll have to try it)

then, when you blit the backgrounds


blit(..., x - BACK_WIDTH, y - BACK_HEIGHT, ...) //top left tile
blit(..., x, y - BACK_HEIGHT, ...) //top right tile
blit(..., x - BACK_WIDTH, y, ...) //bottom left tile
blit(..., x, y, ...) //bottom right tile


this only works if the backgrounds are the same or greater than the screen, you'll need 9 if the background is smaller than the screen.

edit: x, y are the coordinates of the top left corner of the bottom right background

[edited by - billybob on March 6, 2003 10:26:39 PM]

Share this post


Link to post
Share on other sites