VgaGames4 - miscellaneous man-pages

[.. upper level ..]

vg4->misc->bgposition_init()

Positioning background-image: initialize.

SYNTAX
void vg4->misc->bgposition_init(int bg_w, int bg_h, int move_pixel, int win_percent)

FUNCTION PARAMETERS
bg_w Width of background-image
bg_h Height of background-image
move_pixel Number of pixels per game-loop for moving background
win_percent Centered rectangle on window in percent

DESCRIPTION
Positioning background-image: initialize. A background-image which is greater than the window must be positioned according to an object which shall always be visible, e.g. if the focused object is at the right border of the background-image, the left border of the background-image shall not be visible. The win_percent defines a centered rectangle on window in percent, in which the object can move without background-positioning. E.g. if the value is 100 the object can move in the whole window without background-positioning. E.g. if the value is 50 the object can move in half of the window's width and height without background-positioning. The move_pixel is the velocity of the background-positioning to get the object centered again, the value should always be greater than the moving-value of the object. This function can be used at any time to reinitialize background-positioning.

EXAMPLE
struct VG_Image *bgimg;
int bgwidth, bgheight;

/* load background-image and get size */
bgimg = vg4->image->load("background.bmp");
vg4->image->getsize(bgimg, NULL, &bgwidth, &bgheight);

/* initialize background-positioning: velocity 2 pixels, centered rectangle 60% of the window */
vg4->misc->bgposition_init(bgwidth, bgheight, 2, 60);

SEE ALSO
vg4->misc->bgposition_getbg() vg4->misc->bgposition_getobj()