No it is not the entire code. I forgot to store the values into the array. I did this and now it works. Well sorta. It grabs all the sprites and moves them all at once. I have to imagine that there has to be a better way to code this then to have a huge if statement for every single sprite I want to move. Here is the whole code. The part I have REM out is the part I want to remove and replace with one if statement or something better.
rem
rem AGK Application
rem
rem Portrait App
SetDisplayAspect( 0.66 )
background = CreateSprite ( LoadImage ( "background.jpg" ) )
SetSpritePosition ( background, 0, 0 )
setPhysicsGravity(0,0)
global dim spriteI[8]
loadImage (1,"1.jpg")
loadImage (2,"2.jpg")
loadImage (3,"3.jpg")
loadImage (4,"4.jpg")
loadImage (5,"5.jpg")
loadImage (6,"6.jpg")
loadImage (7,"7.jpg")
loadImage (8,"8.jpg")
loadImage (9,"Lbar.jpg")
loadImage (10,"Sbar.jpg")
spriteI[1] = createSprite (1)
setSpriteSize(spriteI[1],10,-1)
setSpritePosition(spriteI[1],35,30)
setSpritePhysicsOn(spriteI[1],2)
setSpriteDepth(spriteI[1],10)
setSpriteshape(spriteI[1],2)
spriteI[2] = createSprite (2)
setSpriteSize(spriteI[2],10,-1)
setSpritePosition(spriteI[2],45,30)
setSpritePhysicsOn(spriteI[2],2)
setSpriteDepth(spriteI[2],10)
setSpriteShape(spriteI[2],2)
spriteI[3] = createSprite (3)
setSpriteSize(spriteI[3],10,-1)
setSpritePosition(spriteI[3],55,30)
setSpritePhysicsOn(spriteI[3],2)
setSpriteDepth(spriteI[3],10)
spriteI[4] = createSprite (4)
setSpriteSize(spriteI[4],10,-1)
setSpritePosition(spriteI[4],35,36.6)
setSpritePhysicsOn(spriteI[4],2)
setSpriteDepth(spriteI[4],10)
spriteI[5] = createSprite (5)
setSpriteSize(spriteI[5],10,-1)
setSpritePosition(spriteI[5],45,36.6)
setSpritePhysicsOn(spriteI[5],2)
setSpriteDepth(spriteI[5],10)
spriteI[6] = createSprite (6)
setSpriteSize(spriteI[6],10,-1)
setSpritePosition(spriteI[6],55,36.6)
setSpritePhysicsOn(spriteI[6],2)
setSpriteDepth(spriteI[6],10)
spriteI[7] = createSprite (7)
setSpriteSize(spriteI[7],10,-1)
setSpritePosition(spriteI[7],35,43.2)
setSpritePhysicsOn(spriteI[7],2)
setSpriteDepth(spriteI[7],10)
spriteI[8] = createSprite (8)
setSpriteSize(spriteI[8],10,-1)
setSpritePosition(spriteI[8],45,43.2)
setSpritePhysicsOn(spriteI[8],2)
setSpriteDepth(spriteI[8],10)
createSprite (9,Lbar)
setSpriteSize(9,34,2)
setSpritePosition(9,33.25,28)
setSpritePhysicsOn(9,1)
setSpriteDepth(9,10)
createSprite (10,Lbar)
setSpriteSize(10,34,2)
setSpritePosition(10,33.25,50)
setSpritePhysicsOn(10,1)
setSpriteDepth(10,10)
createSprite (11,Sbar)
setSpriteSize(11,2,20)
setSpritePosition(11,33.25,30)
setSpritePhysicsOn(11,1)
setSpriteDepth(11,10)
createSprite (12,Sbar)
setSpriteSize(12,2,20)
setSpritePosition(12,65.5,30)
setSpritePhysicsOn(12,1)
setSpriteDepth(12,10)
highScore = 0
score = 0
do
print ("Score: " +str(score))
For i = 1 to 8
if getPointerPressed()=1
hit = getSpriteHitTest(spriteI[i], getPointerX(), getPointerY())
if hit>0
rem sprite picked up
picked = spriteI[1]
pX = getPointerX()
pY = getPointerY()
endif
else
if picked>0
if getPointerState()>0
rem Sprite being dragged
cX = getPointerX()
cY = getPointerY()
setSpritePosition(picked,getSpriteX(spriteI[i])+cX-pX,getSpriteY(spriteI[i])+cY-pY)
pX = cX
pY = cY
else
rem Sprite Dropped
picked=0
endif
endif
endif
next i
remstart
if getPointerPressed()=1
hit = getSpriteHitTest(2, getPointerX(), getPointerY())
if hit>0
rem sprite picked up
picked2 = 2
pX = getPointerX()
pY = getPointerY()
endif
else
if picked2>0
if getPointerState()>0
rem Sprite being dragged
cX = getPointerX()
cY = getPointerY()
setSpritePosition(picked2,getSpriteX(2)+cX-pX,getSpriteY(2)+cY-pY)
pX = cX
pY = cY
else
rem Sprite Dropped
picked2=0
score = score + 1
endif
endif
endif
if getPointerPressed()=1
hit = getSpriteHitTest(3, getPointerX(), getPointerY())
if hit>0
rem sprite picked up
picked3 = 3
pX = getPointerX()
pY = getPointerY()
endif
else
if picked3>0
if getPointerState()>0
rem Sprite being dragged
cX = getPointerX()
cY = getPointerY()
setSpritePosition(picked3,getSpriteX(3)+cX-pX,getSpriteY(3)+cY-pY)
pX = cX
pY = cY
else
rem Sprite Dropped
picked3=0
endif
endif
endif
if getPointerPressed()=1
hit = getSpriteHitTest(4, getPointerX(), getPointerY())
if hit>0
rem sprite picked up
picked4 = 4
pX = getPointerX()
pY = getPointerY()
endif
else
if picked4>0
if getPointerState()>0
rem Sprite being dragged
cX = getPointerX()
cY = getPointerY()
setSpritePosition(picked4,getSpriteX(4)+cX-pX,getSpriteY(4)+cY-pY)
pX = cX
pY = cY
else
rem Sprite Dropped
picked4=0
endif
endif
endif
if getPointerPressed()=1
hit = getSpriteHitTest(5, getPointerX(), getPointerY())
if hit>0
rem sprite picked up
picked5 = 5
pX = getPointerX()
pY = getPointerY()
endif
else
if picked5>0
if getPointerState()>0
rem Sprite being dragged
cX = getPointerX()
cY = getPointerY()
setSpritePosition(picked5,getSpriteX(5)+cX-pX,getSpriteY(5)+cY-pY)
pX = cX
pY = cY
else
rem Sprite Dropped
picked5=0
endif
endif
endif
if getPointerPressed()=1
hit = getSpriteHitTest(6, getPointerX(), getPointerY())
if hit>0
rem sprite picked up
picked6 = 6
pX = getPointerX()
pY = getPointerY()
endif
else
if picked6>0
if getPointerState()>0
rem Sprite being dragged
cX = getPointerX()
cY = getPointerY()
setSpritePosition(picked6,getSpriteX(6)+cX-pX,getSpriteY(6)+cY-pY)
pX = cX
pY = cY
else
rem Sprite Dropped
picked6=0
endif
endif
endif
if getPointerPressed()=1
hit = getSpriteHitTest(7, getPointerX(), getPointerY())
if hit>0
rem sprite picked up
picked7 = 7
pX = getPointerX()
pY = getPointerY()
endif
else
if picked7>0
if getPointerState()>0
rem Sprite being dragged
cX = getPointerX()
cY = getPointerY()
setSpritePosition(picked7,getSpriteX(7)+cX-pX,getSpriteY(7)+cY-pY)
pX = cX
pY = cY
else
rem Sprite Dropped
picked7=0
endif
endif
endif
if getPointerPressed()=1
hit = getSpriteHitTest(8, getPointerX(), getPointerY())
if hit>0
rem sprite picked up
picked8 = 8
pX = getPointerX()
pY = getPointerY()
endif
else
if picked8>0
if getPointerState()>0
rem Sprite being dragged
cX = getPointerX()
cY = getPointerY()
setSpritePosition(picked8,getSpriteX(8)+cX-pX,getSpriteY(8)+cY-pY)
pX = cX
pY = cY
else
rem Sprite Dropped
picked8=0
endif
endif
endif
remend
Sync()
loop