im very confused as this code works when in my do loop directly but when i put it in a function in the loop it seems to run through the code once. i print the "explotime that is supposed to increase to 200 but it stays at one so i know its passing throuhg at least once
global explodeone as integer
global startexplodex as integer
global startexplodey as integer
global explodeup as integer
global explodedown as integer
global exploding as integer
global esplotime as integer
explotime =0
exploding = 0
explodeup = 0
explodeup=0
explodeone=0
function granadethrow()
if explodeone = 0
SetSpritePosition(explode.id,player.x,player.y)
endif
///
if (GetPointerPressed ( ) = 1 )
if GetSpriteHitTest (grenadebut, screentoworldx (GetPointerX ( )), GetPointerY ( ) ) = 1
startexplodex = getspritex(explode.id)
startexplodey = getspritey(explode.id)
explodeone = 1
endif
endif
///
if explodeone=1
if getspritey(explode.id) > startexplodey-200 and explodedown=0
explodeup=1
explodedown=0
endif
if getspritey(explode.id) < startexplodey-200 and explodedown=0
explodeup=0
explodedown=1
endif
if explodeup=1 and exploding = 0
SetSpritePosition(explode.id,getspritex(explode.id)+10,getspritey(explode.id)-10)
endif
if explodedown=1 and exploding = 0
SetSpritePosition(explode.id,getspritex(explode.id)+10,getspritey(explode.id)+10)
endif
if getspritey(explode.id)>startexplodey+GetSpriteHeight(player.id) and exploding = 0
exploding = 1
SetSpritePosition(explode.id, getspritex(explode.id)-250,getspritey(explode.id)-250)
endif
if exploding = 1
setspritesize(explode.id,600,500)
if explotime=0
playsprite(explode.id,10,1,2,31)
endif
explotime = explotime+1
if explotime >=200
exploding=0
explotime=0
explodedown=0
explodeup=0
explodeone=0
SetSpriteFrame(explode.id,1)
setspritesize(explode.id,80,50)
SetSpritePosition(explode.id,player.x,player.y)
endif
endif
endif
endfunction