Background

Setting the background image for B4GL.

Dim backgroundImage, bgsprite

Create the variable

backgroundImage = LoadTexture("Background.jpg")
bgSprite = NewSprite(backgroundImage)

Load the texture, then create a new sprite named bgSprite with the texture backgroundImage.

SprSetPos(320,240)
SprSetSize(640, 480)

Set the position and size. 640x480 is the window size. 320,240 is the center because the sprite's origin is it's center.

SprSetZOrder(3)

Set the ZOrder to 3. Whatever has a zOrder of less than 3 will be drawn on top of the background.

SprSetColor(0,255,0)
DrawText()

This changes the background's colour. It uses RGB (Red, Green, Blue) values, with a max value of 1 for each colour (for less of a colour, use a decimal number e.g. 0.5). So 0,1,0 is Blue, 1,0,0 is Red, and 0,0,1 is Green.
Then, DrawText() updates the screen so we can see the change in colour to it.

Complete code:

Dim backgroundImage

backgroundImage = LoadTexture("Background.jpg")
bgSprite = NewSprite(backgroundImage)
SprSetPos(320,240)
SprSetSize(640, 480)
SprSetZOrder(3)
SprSetColor(0,255,0)
DrawText()
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution 2.5 License.