Original Post
hi,
is someone could explain to me the following part of code. It comes from the book "teach yourself DirectX7 in 24 hours". It displays a street (made up of 3 bitmap image A, B and C). the goal of this algorithm is to find out the part of each image which will be displayed.
thanks for any help you can give.
// loop through the layers
for (int i=0;i.parallax;
// set position of first object
long obj_pos=layers[i].start_x+
(screen_pos-layers[i].start_x)
/layers[i].width;
// loop through objects until off right side of screen
while (obj_pos=screen_pos) {
// yes, calculate the offset to the left edge of the screen
int screen_x=obj_pos-screen_pos;
// clip the object if necessary
rct.left=0;
rct.top=0;
rct.right=layers[i].width;
rct.bottom=layers[i].height;
// test for clipping
if (screen_x<0) {
rct.left-=screen_x;
screen_x=0;
} else if (screen_x+rct.right>640) {
rct.right=640-screen_x;
}
if (rct.bottom+layers[i].start_y>480) {
rct.bottom=480-layers[i].start_y;
}
// draw the object to the screen
lpDDSBack->BltFast(screen_x,layers[i].start_y,layers[i].surf,&rct,layers[i].blit_flags);
}
// increment to next object position
obj_pos+=layers[i].interval;
}
}