BITPASTETOINDEX

Synopsis
BITPASTETOINDEX index x y
Description

Pastes the entire image that was "cut" with BITCUT to the x, y coordinate of the bitmap at the index input. Don't confuse the indices here; the index input specifies the index to paste to, whereas SETBITINDEX specifies the index to copy from.

The x and y inputs specify the coordinates on the destination bitmap where the lower-left corner of the source bitmap is pasted.

This command is useful for producing flicker-free animation. For example, let's say you have a ball rolling across a background. You have to erase the ball, put the background back, and draw the ball in its new position. The problem is that the user momentarily sees a screen with no ball after you erase it, but before you draw it in its new position. This is called "flicker". However, if you create the entire animation frame in memory (by using BITPASTETOINDEX) and BITPASTE each frame to the screen in a single instruction, then the user doesn't see any flicker.

Note that the destination index must already have an image to paste to.

Example
; Draw a red block 100x100 in Bitmap Buffer 1
SETBITINDEX 1
SETFLOODCOLOR [255 0 0]
BITBLOCK 100 100
BITCOPY 100 100

; Draw a green block 50x50 in Bitmap Buffer 2
CLEARSCREEN
SETBITINDEX 2
SETFLOODCOLOR [0 255 0]
BITBLOCK 50 50
BITCOPY 50 50

; Reserve 100x100 space in Bitmap Buffer 3
CLEARSCREEN
SETBITINDEX 3
BITCOPY 100 100

; Copy 1 to 3
SETBITINDEX 1
BITPASTETOINDEX 3 0 0

; Copy 2 to 3
SETBITINDEX 2
BITPASTETOINDEX 3 25 25

; Paste 3 to Screen
SETBITINDEX 3
BITPASTE
See Also
SETBITMODE

SourceForge.net Logo