AGK has no concept of what a red and green sprite are, you need to define it and use one of many functions designed for contact/collision checking
Look at: GetSpriteInBox()
or use collision checking functions (see help file)
or use something like this
Type tRect
x1 as float
y1 as float
x2 as float
y2 as float
EndType
Type tPoint
x as float
y as float
EndType
// is the tPoint inside the tRect
Function IsPointInRect(pt as tPoint, rect as tRect)
result as integer : result = 0
if pt.x>rect.x1 and pt.x<rect.x1+rect.x2 and pt.y>rect.y1 and pt.y<rect.y1+rect.y2
result=1
endif
EndFunction result
there are many ways to know when a sprite touches another sprite, using colors/memblocks is advanced stuff and have zero benefit over using native functions.