'scratchcard' image possible?

Blitz3D Forums/Blitz3D Beginners Area/'scratchcard' image possible?

767pilot(Posted 2005) [#1]
Is it possible to have 2 images, say 100*100 on top of each other, the bottom image a picture and the top just plain grey and coding so that when the mouse button is held down over the image it removes the part of the grey image the mouse is over revealing the picture underneath, exactly like a scratchcard?

I am interested in making a game similar to one of the minigames on wario warez DS where the grey was scratched off on the touchscreen of the nintendo ds to reveal a coin

Thanks


WolRon(Posted 2005) [#2]
Is it possible
Yes

Any other questions?


TomToad(Posted 2005) [#3]
yes. Just create an image the same size as the picture and fill it with grey. When you "scratch", just write black pixels to it, then DrawBlock the picture and DrawImage the grey image. Where you filled with black should become transparent and show through.
Hopefully that explaination wasn't too confusing. :-)


WolRon(Posted 2005) [#4]
Think this should do it
(hasn't been tested)
Graphics 800, 600
SetBuffer BackBuffer()
Color 0, 0, 0

image1 = LoadImage("image1.png") ;background
image2 = LoadImage("image2.png") ;gray

While Not KeyHit(1)
  If MouseDown(1)
    SetBuffer ImageBuffer(image2)
    Plot MouseX(), MouseY()
    SetBuffer BackBuffer()
  EndIf

  Drawblock image1, 0, 0
  DrawImage image2, 0, 0 ;NOTE the drawIMAGE command
  Flip
Wend