Ok so I am trying something new and different and practicing new ways of doing things.

I have a grid of sprites, marbles lined up together on a grid and I can move each one to my pointer if selected, but I need to limit how far I can move them

due to there past positions and cell size. I am trying one way and it works but only for one side of its x pos and not the other.

Here is a example of my code.

if gride[x,y].Selected_1=1 and GetPointerState()=1
gride[x,y].Newposx=GetSpriteXByOffset(gride[x,y].sprite)
gride[x,y].Newposy=GetSpriteYByOffset(gride[x,y].sprite)
if gride[x,y].Newposx<gride[x,y].oldposx+CELL_SIZE then SetSpritePositionByOffset(gride[x,y].sprite, GetPointerX ( ), GetPointerY ( ))
SetSpriteDepth(gride[x,y].sprite,0)
endif

I tried many things, even this but it does not work for both sides.

if gride[x,y].Newposx<gride[x,y].oldposx+CELL_SIZE or gride[x,y].Newposx>gride[x,y].oldposx+CELL_SIZE then SetSpritePositionByOffset(gride[x,y].sprite, GetPointerX ( ), GetPointerY ( ))

I fell like it is so simple but I do not see it.

Thanks for any help of understanding on this.

In case anyone is wondering I am setting up different games in my match three game and this is one of the other games. You have to move each marble over the pets then they drop on them and explode. but they have to be limited to only the next slot over from there own position.

This is the whole function I created if it helps.

function MoveGrid()
for y = 0 to BOARD_SIZE_Y
for x = 0 to BOARD_SIZE_X
if ( GetPointerPressed ( ) = 1 )
hit = GetSpriteHitTest (gride[x,y].sprite, GetPointerX ( ), GetPointerY ( ) )
if hit=1 then gride[x,y].Selected_1=1
gride[x,y].oldposx=GetSpriteXByOffset(gride[x,y].sprite)
gride[x,y].oldposy=GetSpriteYByOffset(gride[x,y].sprite)
endif
if gride[x,y].Selected_1=1 and GetPointerState()=1
gride[x,y].Newposx=GetSpriteXByOffset(gride[x,y].sprite)
gride[x,y].Newposy=GetSpriteYByOffset(gride[x,y].sprite)
if gride[x,y].Newposx<gride[x,y].oldposx+CELL_SIZE then SetSpritePositionByOffset(gride[x,y].sprite, GetPointerX ( ), GetPointerY ( ))
SetSpriteDepth(gride[x,y].sprite,0)
endif
if gride[x,y].Selected_1=1 and GetPointerReleased()=1
gride[x,y].Selected_1=0
SetSpritePositionByOffset(gride[x,y].sprite,gride[x,y].oldposx,gride[x,y].oldposy)
endif
if gride[x,y].Selected_1=0
SetSpriteDepth(gride[x,y].sprite,1)
endif
next x
next y
endfunction