moving 1 to another position if keyhit is true?

BlitzMax Forums/BlitzMax Beginners Area/moving 1 to another position if keyhit is true?

Hi Ryan. I have made some progress although with a few problems.

Heres my movement code :

Function moveblock()

	If KeyHit(KEY_RIGHT)

   		array[BoxPosx / 10, BoxPosx Mod 10] = 0
   		BoxPosx = BoxPosx + 10
   		array[BoxPosx / 10, BoxPosx Mod 10] = 1
		
	EndIf
	
	If KeyHit(KEY_LEFT)
	
   		array[BoxPosx / 10, BoxPosx Mod 10] = 0
   		BoxPosx = BoxPosx - 10
   		array[BoxPosx / 10, BoxPosx Mod 10] = 1

	EndIf 
	
	If KeyHit(KEY_DOWN)
	
   		array[BoxPosx / 10, BoxPosx Mod 10] = 0
   		BoxPosx = BoxPosx + 1
   		array[BoxPosx / 10, BoxPosx Mod 10] = 1	

	EndIf
	
	If KeyHit(KEY_UP)
	
   		array[BoxPosx / 10, BoxPosx Mod 10] = 0
   		BoxPosx = BoxPosx - 1
   		array[BoxPosx / 10, BoxPosx Mod 10] = 1	

	EndIf

		
End Function



I've changed ArraySize to 10 and have set up 2 globals "BoxPosx & BoxPosy". Although there doesnt appear to be a need for BoxPosY

It does what I want it to do even though I still dont get the maths for it.

   array[BoxPosx / 10, BoxPosx Mod 10] = 0
   BoxPosx = BoxPosx - 1
   array[BoxPosx / 10, BoxPosx Mod 10] = 1


Why is it like this?

"array[BoxPosx / 10" = Dividing boxposx by 10 to get what value?

Then :

",BoxPosx mod 10] = 1" = Does what? I dont get whats happening.