how to subtract the move of a player
Posted: Sat Jan 26, 2013 2:17 am
im having a problem regarding on how to make the player move back. i have a gameboard for snake and ladders. and i only have 36 grids. each grids has a specific location. my problem is when the player reaches to the last line of the grid. w/c means the player reaches the last line of the grid. when the dice stops at 4,5,or 6 and it would be the number of dice stopped > 36, the player should move backward regarding the number of dice given. i have here the code , at the first condition, it works but when it tried to move n the same condition, the player goes down to the first line of the grid. i dont know what is wrong but i really need help for this . here's the code
Code: Select all
on movePone
--numdice1 refers to the current number of box location
--sdice referes to the number of dice
put (numdice1+sdice) into sdice
put setofLocations(sdice) into pMoveOneLoc
getTheLocation "plyrOne"
if sdice > 36 then
put (36-sdice) into sdice
put setofLocations(sdice) into pMoveOneLoc
move btn "plyrOne" from theCurrentLocation to pMoveOneLoc in 100 ticks
else
move btn "plyrOne" from theCurrentLocation to pMoveOneLoc in 100 ticks
end if
put sdice into numdice1
end movePone
on getTheLocation theplayer
put the location of btn theplayer into theCurrentLocation
end getTheLocation
function setofLocations thesum
put "1-458,681*2-554,681*3-651,681*4-748,681*5-842,681*6-932,673*7-931,567*8-841,558*9-747,558*10-650,558*11-553,558*12-458,552*13-458,446*14-553,441*15-650,441*16-749,440*17-842,440*18-932,443*19-932,328*20-841,321*21-748,322*22-650,322*23-554,322*24-458,315*25-458,207*26-553,201*27-650,201*28-748,201*29-842,202*30-932,194*31-932,81*32-842,74*33-748,74*34-651,74*35-553,74*36-458,76" into locationlist
set the itemDel to "*"
put the item thesum of locationlist into holder
set the itemDel to "-"
return the item 2 of holder
end setofLocations
on getTheLocation theplayer
put the location of btn theplayer into theCurrentLocation
end getTheLocation