UPDATE to the above:
I played around a bit more with this and for some reason it didn't work as the code I posted, one of the sprite groups worked the other didn't quiet work, despite the first time I tested it, it all did work, so I decided to investigate this further and created the following code for you to test this yourself:
SetVirtualResolution(32,32)
SetWindowSize(768,768,0)
SetDefaultMagFilter(0)
point = CreateSprite(0)
SetSpriteSize(point,1,1)
SetSpriteColor(point,0,255,0,255)
SetSpriteDepth(point,10)
// show pixel grid
TheBackground = CreateSprite(LoadImage("bg.png"))
SetSpriteDepth(TheBackground,100)
for i=1 to 2
CreateText(i,"FAIL")
SetTextColor(i,255,0,0,255)
settextsize(i,3)
SetTextAlignment(i,0)
next
global thex , they , tryx , tryy
theX=16
TheY=16
TryX=4
TryY=10
// this sprite is only to show the bug, hover mouse in red area
TryHere = CreateSprite(0)
SetSpriteDepth(TryHere,51)
SetSpriteSize(TryHere,9,9)
SetSpritePosition(TryHere,TryX,TryY)
SetSpriteColor(TryHere,255,64,64,64)
SetSpriteOffset(TryHere,0,0)
SetSpriteShapeBox(TryHere,0,0,9,9,0)
SetSpriteGroup(TryHere,678) // <- different group
// this is the sprite we are testing for
CollisionGroup = 456
TheSprite = CreateSprite(0)
SetSpriteDepth(TheSprite,50)
SetSpriteSize(TheSprite,8,8)
SetSpritePosition(TheSprite,TheX,TheY)
SetSpriteColor(TheSprite,64,96,240,255)
SetSpriteOffset(TheSprite,0,0)
SetSpriteShapeBox(TheSprite,0,0,8,8,0)
SetSpriteGroup(TheSprite,CollisionGroup)
DO
TestX = Floor(GetRawMouseX())
TestY = Floor(GetRawMouseY())
Print( TestX )
Print( TestY )
SetTextPosition(1,TryX,TryY+2)
SetTextPosition(2,TheX,TheY+2)
SetSpritePosition(TryHere,TryX,TryY)
SetSpritePosition(TheSprite,TheX,TheY)
SetSpritePosition(point,TestX, TestY)
if GetSpriteHitGroup( CollisionGroup, TestX, TestY )
text$="PASS"
SetTextString(2,"PASS")
SetTextColor(2,0,255,0,255)
else
text$="FAIL"
SetTextString(2,"FAIL")
SetTextColor(2,255,0,0,255)
endif
if GetSpriteHitGroup( 678, TestX, TestY )
text2$="PASS"
SetTextString(1,"PASS")
SetTextColor(1,0,255,0,255)
else
text2$="FAIL"
SetTextString(1,"FAIL")
SetTextColor(1,255,0,0,255)
endif
if GetSpriteHitGroup( CollisionGroup, TestX, TestY ) or GetSpriteHitGroup( 678, TestX, TestY )
SetSpriteColor(point,255,0,0,255)
else
SetSpriteColor(point,0,255,0,255)
endif
Print( "Check for TheSprite of CollisionGroup = "+text$)
Print("TryHere sprite coordinates X = "+str(TryX)+" Y = "+str(TryY))
Print( "Check for TryHere of 678 group = "+text2$)
Print("TheSprite sprite coordinates X = "+str(TheX)+" Y = "+str(TheY))
Sync()
TryMove()
TheMove()
LOOP
Function TheMove()
if GetRawKeyPressed(37)
TheX=TheX-1
elseif GetRawKeyPressed(39)
TheX=TheX+1
elseif GetRawKeyPressed(38)
TheY=TheY-1
elseif GetRawKeyPressed(40)
TheY=TheY+1
endif
endfunction
Function TryMove()
if GetRawKeyPressed(65)
TryX=TryX-1
elseif GetRawKeyPressed(68)
TryX=TryX+1
elseif GetRawKeyPressed(87)
TryY=TryY-1
elseif GetRawKeyPressed(83)
TryY=TryY+1
endif
endfunction
The arrow keys move one sprite, the WASD keys move the other and it does appear that there is a certain strange behavour with integers. I have not tried using floats as Virtual Nomad suggested, but this could be part of the solution, however still strange the behaviour. Test it yourself and you will see. I attach a short video recording of the test I did on this and I don't understand the logic of it, so it could be that Nieb has a valid point on this matter, unless someone with more knowledge and experience can clarify this odd behaviour.
ADD: I just tested the float principle and it appears that Virtual Nomad's solution is correct. The reason being is the integer use instead of float. With floats it works perfect. So I guess you will have to figure out the logic to make this work with the integers, how you gonna do that for the pixel game, good luck with that.
????????