Blitz3D+ Command Reference

TileBlock image[,x][,y][,frame]

Parameters

image - handle of the image to tile

x (optional) - horizontal offset of the tiling; 0 (default)

y (optional) - vertical offset of the tiling; 0 (default)

frame (optional) - frame of an animated image to tile with; 0 (default)

Description

Fills the whole drawing area with copies of an image, ignoring its mask colour.

It is TileImage with transparency switched off: every pixel of the tile is written, mask colour included, so the pattern lands solid. Because nothing needs testing per pixel it is the faster of the two, and it is what you want for the bottom layer of a scene - a seamless texture background, a floor, a night sky - where there is nothing underneath worth preserving. It also saves you a Cls, since it covers everything anyway.

x and y offset where the tiling starts, and the pattern wraps, so stepping them each frame scrolls the background endlessly. That is the classic scrolling-shooter starfield, and layering a masked TileImage on top at a different speed gives you parallax.

Tiling fills the current Viewport, not necessarily the whole screen, so narrow the viewport first if you only want part of the display covered.

See also: TileImage, DrawBlock, Viewport, Cls, LoadImage.

Example

; TileBlock Example
; -----------------

Graphics 640,480,0,2
SetBuffer BackBuffer()

star=LoadImage("media/star1.bmp")
player=LoadImage("media/player.bmp")

scroll#=0

While Not KeyDown(1)

    ; No Cls needed - TileBlock covers every pixel (the mask is ignored),
    ; so a scrolling tiled backdrop doubles as a fast screen clear
    scroll=scroll+1
    TileBlock star,0,scroll

    ; The ship cruises over the scrolling backdrop
    DrawImage player,MouseX(),MouseY()

    Text 0,0,"Move the mouse to fly   Esc: exit"
    Text 0,20,"TileBlock star,0,"+Floor(scroll)+" - tiles the screen, transparency ignored"

    Flip

Wend

End

Index