try using a spritehit test from the middle, not at the edges.
means if u make a hittest at x=20 but the sprite is at x=20.00000001 the test fail because its not inside.
GetSpriteXByOffset( player )
GetSpriteYByOffset( player )
my test:
SetWindowTitle( "TEST Poke" )
SetSyncRate(60,0)
deviceHeight# = GetDeviceHeight()
deviceWidth# = GetDeviceWidth()
IF deviceWidth# > deviceHeight#
practicalWidth# = deviceWidth#
practicalHeight# = deviceHeight#
ENDIF
IF deviceWidth# < deviceHeight#
practicalWidth# = deviceHeight#
practicalHeight# = deviceWidth#
ENDIF
GLOBAL practicalWidth# : GLOBAL practicalHeight#
`SetScreenResolution( 640, 420 )
SetWindowSize( practicalWidth#, practicalHeight#, 0 )
SetWindowSize( GetMaxDeviceWidth(), GetMaxDeviceHeight(), 0 )
SetDisplayAspect( -1 )
// set display properties
deviceHeight# = GetMaxDeviceHeight()
deviceWidth# = GetMaxDeviceWidth()
`SetVirtualResolution( 1024, 768 )
`SetVirtualResolution( 1920, 1080 )
PrevDeviceOrientation = GetOrientation()
CurrentDeviceOrientation = GetOrientation()
IF PrevDeviceOrientation = 1 OR PrevDeviceOrientation = 2
SetVirtualResolution( practicalWidth#, practicalHeight# )
````SetVirtualResolution( practicalHeight#, practicalWidth# )
ENDIF
IF PrevDeviceOrientation = 3 OR PrevDeviceOrientation = 4
SetVirtualResolution( practicalHeight#, practicalWidth# )
````SetVirtualResolution( practicalWidth#, practicalHeight# )
ENDIF
SetOrientationAllowed( 1, 1, 1, 1 )
SetClearColor(2.00,2.00,2.00)
SetPrintColor(255,255,255, 255)
SetPrintSize( 30 )
`---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//Load stuff
SetDefaultMagFilter(0)
SetDefaultMinFilter(0)
loadImage(1,"dummy.png")
loadImage(2,"dummy2.png")
loadImage(1000,"liliycove 8216.png")
loadImage(1001,"sea tiles 1.png")
if 1=1
GLOBAL spr0 = 100
createSprite(spr0,1000)
setSpriteVisible(spr0,1)
SetSpriteDepth ( spr0, 10 )
endif
rem Player
GLOBAL player
player=createSprite(2)
setSpriteVisible(player,1)
SetSpriteTransparency( player, 0 )
setSpritePosition(player, (19*16), (10*16))
SetSpriteDepth (player, 5 )
REM Obstacle
GLOBAL obstacle
obstacle=createSprite(0)
setSpriteVisible(obstacle,1)
SetSpriteTransparency( obstacle, 0 )
`SetSpriteAnimation ( player, 16, 16, 8 )
`PlaySprite ( player, 5, 1, 1, 8 )
`setSpriteSize(NPCNum,200,200)
setSpritePosition(obstacle, (10*16), (10*16))
SetSpriteDepth (obstacle, 10 )
SetSpriteColor(obstacle,255,0,0,255)
SetViewZoom( 1.0 )
SetViewOffset(GetSpriteX( player ) - (30*10), GetSpriteY( player ) - (16*10) )
do
x#=0
y#=0
IF GetRawKeyState( 39 ) = 1
x#=1
ENDIF
IF GetRawKeyState( 37 ) = 1
x#=-1
ENDIF
IF GetRawKeyState( 40 ) = 1
y#=1
ENDIF
IF GetRawKeyState( 38 ) = 1
y#=-1
ENDIF
SetSpritePosition(player,getspritex(player)+x#,getspritey(player)+y#)
moveTargetX# = GetSpriteXByOffset( player )
moveTargetY# = GetSpriteYByOffset( player )
DrawEllipse( moveTargetX#, moveTargetY#,16,16,MakeColor(255,0,0),MakeColor(255,0,0),0)
DrawEllipse( moveTargetX#+16, moveTargetY#,2,2,MakeColor(255,255,0),MakeColor(255,255,0),0)
DrawEllipse( moveTargetX#-16, moveTargetY#,2,2,MakeColor(255,255,0),MakeColor(255,255,0),0)
DrawEllipse( moveTargetX#, moveTargetY#+16,2,2,MakeColor(255,255,0),MakeColor(255,255,0),0)
DrawEllipse( moveTargetX#, moveTargetY#-16,2,2,MakeColor(255,255,0),MakeColor(255,255,0),0)
print("Debug:")
print("Player " + str(player))
print("obstacle " + str(obstacle))
print( GetSpriteHit( moveTargetX#-16, moveTargetY# ))
print( GetSpriteHit( moveTargetX#+16, moveTargetY# ))
print( GetSpriteHit( moveTargetX#, moveTargetY#-16 ))
print( GetSpriteHit( moveTargetX#, moveTargetY#+16 ))
Sync()
loop
AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)