It can be done using image memblocks
1. Make a memblock from the silver image
2. As the user scratches the panel, set the alpha byte on the areas scratched to 0, in the memblock
3. Copy the memblock back to the screen image/sprite.
You should do some pre-calculations of how to navigate the memblock to speed things up at runtime. For example, how to traverse from pixel to pixel both horizontally and vertically.
You only need to createImageFromMemblock(), you don't need to keep copying the image back into a memblock after the first creation.
If you aren't doing anything else, you could make life really easy for yourself. You can create/delete 200x200 pixel memblocks and images at over 700FPS (code below used to test this). This way you can paste a black circle onto a white offscreen image where they scratch. Convert this to a memblock each cycle. Use it as a template to find the pixels you want to make transparent (the black pixels) in the silver image memblock.
You can also alternate to double+ the speed. In cycle 1, create the memblock. In cycle 2, calculate the transparent pixels and move the memblock back to the onscreen image. Or...
In cycle 1, create the memblock. In cycle 2, calculate the transparent pixels. In cycle 3 move the memblock back to the onscreen image.
setVirtualResolution(1024,768)
setsyncrate(0,1)
img = getimage(1,1,200,200)
do
mb = CreateMemblockFromImage(img)
im = CreateImageFromMemblock(mb)
DeleteMemblock(mb)
print ("FPS: " + str(ScreenFPS(),0))
sync()
loop
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt