*********************************************
it looks like you can't use this code from the default editor.
Replace the tutorial source code (code example 2) with the following code which does work.
The code is identical. The comments have been removed, and this fixes the problem!
global pixpitch
global maskImage
maskImage = 100
global maskMemblock
maskMemblock = 10
dim maskStage(255)
set display mode 800,600,32
sync on
SYNC RATE 100
set text opaque
loadMask("mask1.bmp",11)
load image "Image1.jpg", 1, 1
load image "Image2.jpg",2,1
make memblock from image 1,1
make memblock from image 2,2
lock pixels
pixpitch = get pixels pitch()
unlock pixels
memblockWipe(1,11)
delay()
memblockWipe(2,11)
delay()
delay()
delay()
function memblockWipe(newImage, mask)
sh = screen height()
sw = screen width()
sd = screen depth()
sb = sw * (sd / 8)
pointer = 0
for n = 0 to 255
lock pixels
for m = pointer to pointer + (maskStage(n) - 1)
pixel = memblock dword(mask, m * 4)
pixelline = pixel / sw
pixelcolumn = pixel - (pixelline * sw)
screenPosition = (pixelline * pixpitch) + (pixelcolumn * (sd / 8))
newImagePosition = (pixelline * sb) + (pixelcolumn * (sd / 8))
copy memory get pixels pointer() + screenposition, get memblock ptr(newImage) + newImagePosition + 12, sd / 8
next m
inc pointer, maskStage(n)
unlock pixels
text 5,5, str$(screen fps())
sync
next n
`************************************************************
endfunction
function delay()
time = timer()
while timer() < time + 1000
text 5,5, str$(screen fps())
sync
endwhile
endfunction
function LoadMask(image$, memblock)
load image image$, maskImage, 1
make memblock from image maskMemblock, maskImage
delete image maskImage
make memblock memblock, 480000 * 4
sb = memblock dword(maskMemblock, 8) / 8
print "Loading Mask Data (~5 seconds)..." : Sync : Sync
nextByte = 0
for n = 0 to 255
pixelcount = 0
for m = 0 to 479999
if memblock byte(maskMemblock, (m*sb) + 14) = n
write memblock dword memblock, nextByte, (m)
inc nextByte, 4
inc pixelCount, 1
endif
next m
maskStage(n) = pixelCount
next n
endfunction
This competition runs alongside the September Newsletter Tutorial on Memblocks. The closing date is midnight, Friday October 14th 2005.
The Game Creators have kindly donated two prizes for the winners.
The Competition details and prizes can be found in the attached download. In contrast to regular competitions, no coding is necessary, but it is still in the vein of game making. Confused? Download the details and all will be revealed.
*** Competition Instructions ***
* The download is a DB Pro application, illustrating what is required of entrants.