runState = "True"
while(runState)
ySpeed = ySpeed + g
If ySpeed > maxYSpeed Then
ySpeed = maxYSpeed
EndIf
If ySpeed < -maxYSpeed Then
ySpeed = -maxYSpeed
EndIf
If xSpeed > maxXSpeed Then
xSpeed = maxXSpeed
EndIf
If xSpeed < -maxXSpeed Then
xSpeed = -maxXSpeed
EndIf
x = x + xSpeed
y = y + ySpeed
If (x+SIZE+xSpeed >= width or x <= 0) Then
Sound.PlayClick()
xSpeed = -xSpeed
If x<=0 Then
x=1
Else
x=width-SIZE -1
EndIf
EndIf
If (y <= 0) Then
Sound.PlayClick()
ySpeed = -ySpeed
y=1
EndIf
padY = Shapes.GetTop (pad)
padX = Shapes.GetLeft(pad)
If (y+SIZE > padY and x+SIZE >= padX and x <= padX + padSize) Then
Sound.PlayClick()
padPoint = ((x + HALF_SIZE )-(padX+halfPadSize))
ySpeed = -(ySpeed*0.50 + (halfPadSize+SIZE-Math.Abs(padPoint))/30)
xSpeed = xSpeed + padPoint/20
y = padY-SIZE
EndIf
Shapes.Move(ball, x, y)
xIndex1 = Math.Floor(x / BOX_WIDTH)
yIndex1 = Math.Floor(y / BOX_HEIGHT)
xIndex2 = Math.Floor((x+SIZE) / BOX_WIDTH)
yIndex2 = Math.Floor((y+SIZE) / BOX_HEIGHT)
xCrash = 0
yCrash = 0
If boxEnable[xIndex1][yIndex1] Then
xCrash = 1
yCrash = 1
EndIf
If boxEnable[xIndex2][yIndex1] Then
xCrash = xCrash-1
yCrash = yCrash+1
EndIf
If boxEnable[xIndex1][yIndex2] Then
xCrash = xCrash+1
yCrash = yCrash-1
EndIf
If boxEnable[xIndex2][yIndex2] Then
xCrash = xCrash-1
yCrash = yCrash-1
EndIf
If boxEnable[xIndex1][yIndex1] Then
Sound.PlayClick()
boxEnable[xIndex1][yIndex1]="False"
Shapes.Remove(box[xIndex1][yIndex1])
boxCount = boxCount -1
EndIf
If boxEnable[xIndex2][yIndex1] Then
Sound.PlayClick()
boxEnable[xIndex2][yIndex1]="False"
Shapes.Remove(box[xIndex2][yIndex1])
boxCount = boxCount -1
EndIf
If boxEnable[xIndex1][yIndex2] Then
Sound.PlayClick()
boxEnable[xIndex1][yIndex2]="False"
Shapes.Remove(box[xIndex1][yIndex2])
boxCount = boxCount -1
EndIf
If boxEnable[xIndex2][yIndex2] Then
Sound.PlayClick()
boxEnable[xIndex2][yIndex2]="False"
Shapes.Remove(box[xIndex2][yIndex2])
boxCount = boxCount -1
EndIf
If boxCount = 0 Then
Goto GameClear
EndIf
If xCrash <> 0 Then
xSpeed = -xSpeed * 0.9
EndIf
If yCrash <> 0 Then
ySpeed = -ySpeed * 0.9
EndIf
Program.Delay(7)
If (y > height) Then
Goto GameOVer
EndIf
EndWhile