Recently I've decided to create a re-make of the classic Arkanoid game. I decided to program the game's logic first and use generic graphics until I get it working properly. However, I've run into an interesting problem with the ball not wanting to deflect off of the bricks properly. Either the ball wants to take out all of the bricks on the X-axis or if I change the code a bit, it wants to take them all out on the Y-axis. The funny thing is, I've used this exact piece of code in another project which does work correctly. The function that deals with the ball and bricks is below. Any help would be appreciated! Thanks!
FUNCTION DisplayAndCheckBlocks()
BlockCount = 0
Width = SPRITE WIDTH(BrickSprite)
Height = SPRITE HEIGHT(BrickSprite)
CenterOfBall = SPRITE X(BallSprite) + SPRITE WIDTH(BallSprite) / 2
LeftSideBlock = SPRITE X(BallSprite)
RightSideBlock = SPRITE X(BallSprite) + SPRITE WIDTH(BallSprite)
FOR i = 1 TO 5
FOR y = 1 TO 8
IF BlockArray(i, y) = 1
INC BlockCount
SPRITE BrickSprite, 100 + Width * y, 80 + Height * i, BrickImage
PASTE SPRITE BrickSprite, 100 + Width * y, 80 + Height * i
IF SPRITE COLLISION(BrickSprite, BallSprite)
PLAY SOUND BallBounce
BlockArray(i, y) = 0
IF CenterOfBall < LeftSideBlock OR CenterOfBall > RightSideBlock
SpeedX = SpeedX * -1
ELSE
SpeedY = SpeedY * -1
ENDIF
ENDIF
ENDIF
NEXT y
NEXT i
IF BlockCount = 0 THEN GameState$ = "quit"
ENDFUNCTION