Thank you Virtual Nomad for your draft source code .
Some remarks about your sprite dummy. It is no longer necessary to do this :
img_dummy = CreateImageColor(0,0,0,0) `create 1px dummy sprites to check top left and bottom right corners of the hero sprite for collision vs land sprite
spr_dummy1= CreateSprite(img_dummy)
SetSpriteSize(spr_dummy1,1,1)
You can do this directly with the new function
CreateDummySprite
I like your 1px transparent technique.
I refined my collision detection technique by using this other function: GetSpriteHit
I get what I want here is the code:
// Project: GetCollision01
// Created: 2018-12-06
// author : patmaba
// thread : https://forum.thegamecreators.com/thread/223392
SetWindowSize( 1024, 768, 0 )
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
UseNewDefaultFonts( 1 )
SetPrintSize(20)
img_sea = CreateImageColor( 0, 0, 255, 255 )
img_land = CreateImageColor( 0, 255, 0, 255 )
img_hero = CreateImageColor( 255, 0, 0, 255 )
// sea Area
spr_sea= CreateSprite( img_sea )
SetSpriteSize( spr_sea, 300,300)
SetSpriteDepth(spr_sea, 30)
SetSpritePosition( spr_sea, 300, 300)
// land Area
spr_land= CreateSprite( img_land )
SetSpriteSize( spr_land, 200,200)
SetSpriteDepth(spr_land, 20)
SetSpritePosition( spr_land, 320, 320)
// hero Area
spr_hero= CreateSprite( img_hero )
SetSpriteSize( spr_hero, 32,32)
SetSpriteDepth(spr_hero, 10)
do
// mouse position
mx = GetRawMouseX()
my = GetRawMouseY()
// hero corner + 1 pixel size
rx = mx-1 // right x position
lx = mx+33 // left x position
ty = my-1 // top y
by = my+33 // botom y
// draw the hero
SetSpritePosition( spr_hero, mx, my)
// Draw graphically the hero corner
col = MakeColor(255,255,255)
DrawEllipse(rx,ty,2,2,col,col,0)
DrawEllipse(lx,ty,2,2,col,col,0)
DrawEllipse(rx,by,2,2,col,col,0)
DrawEllipse(lx,by,2,2,col,col,0)
Print( "spr_sea="+str(spr_sea)+ ", spr_land="+str(spr_land) + ", spr_hero="+str(spr_hero))
Print("")
Print( "Collision hero vs sea :" +str(GetSpriteCollision( spr_hero, spr_sea )) )
Print( "Collision hero vs land:" +str(GetSpriteCollision( spr_hero, spr_land)) )
// Check hero collision corner
Print( "Hero Upper Left hit:" + str(GetSpriteHit(rx, ty)))
Print( "Hero Upper Right hit:" + str(GetSpriteHit(lx, ty)))
Print( "Hero Bottom Left hit:" + str(GetSpriteHit(rx, by)))
Print( "Hero Bottom Right hit:" + str(GetSpriteHit(lx, by)))
Sync()
loop
Thanks to all
patmaba