For something like the example you are telling you can do something like this:
;Sample demo of clicking on a image and having a text displayed
;it's not a well writed code but it's only for demostration pourpose...
Graphics 640,480,32,2
;this command tell Blitz to open a screen 640*480 (the screen resolution),32(the screen colour depht),2(i use the windowed mode...
;1 is fullscreen and 3 is scalable window)
SetBuffer BackBuffer()
;this will tell Blitz to make all the drawing command into the backbuffer...this allows double buffering technique (page flipping
;flicker free display...)
;now i load some graphic...you could load your graphic,just remember to place the bitmap in the same folder of you place
;this snippet of code...
image1=LoadImage("image.bmp") ;this tell blitz to load an image and the image "handle" is image1 (for processing later the image..)
sprite1=LoadImage("sprite1.bmp") ;now we load a simple sprite to move across the screen
While Not KeyHit(1)=True ;the program repeat itself until the ESC key is pressed)
Cls ;this clear the screen...for double buffering
DrawImage (image1,300,300,0) ;this tell blitz to draw the image at 300*300 coordinates and to display frame 0 because we have loaded
;a single frame...)
DrawImage (sprite1,MouseX(),MouseY(),0) ;this tell blitz to draw the sprite at mousex&y position,so every cycle the sprite
;change it's position as you move the mouse)
If ImagesOverlap(sprite1,MouseX(),MouseY(),image1,300,300) And MouseDown(1)=True ;this is the most important part of the code..
;pratically tell blitz to see if the two image are overlapping each other at their respective positionit's the called collision
;checking..)and i add another condition using the boolean operator AND...so if the 2 images overlap each other AND the mousebutton 1
;is held down you achieve what you put AFTER the condition...(i hope i have explained well enough..)
Text 200,200,"You are touching me....i'm shy please stop!!!"
Else
Text 150,150,"Haaa....this is much better... :)"
EndIf ;this end the condition-checking
Flip True ;this will tell blitz to swap the front-buffer and the back-buffer so you have flicker-free image display
Wend
End ;stop the program and exit to windows
|