Okay, I have fixed all the endifs and added them all. I have removed the return and also indented alot here is my new code
`turn window mode on
set window on
`set display mode
set display mode 800, 600, 32
`set sync on
sync on
`set refresh rate to 30
sync rate 30
`hide mouse
hide mouse
`load sprites
load image "ball.png", 1
load image "wall.png", 2
load image "brick.png", 3
load image "quit.png", 4
load image "how to play.png", 5
load image "play game.png", 6
`Load sounds
load sound "pacman.mp3", 1
load sound "death.mp3", 2
load sound "hitbrick.mp3", 3
`Set screen position
xPosition = screen width() / 2
yPosition = screen height() / 2
`generate Sprites
sprite 1, xPosition, yPosition, 1
sprite 2, xPosition, yPosition, 2
sprite 3, xPosition, yPosition, 3
`set score to 0
score = 0
`set lives
lives = 3
`play music
play sound 1
sleep 4000
`show score and lives
do
cls
print "Score: " + str$(score)+ "Lives Left:" + str$(lives) + " Level: " + str$(level)
`move left key
if leftkey() = 1
xPosition = xPosition - 5
if xPosition < 0
xPosition = 0
endif
endif
`move right
if rightkey() = 1
xPosition = xPosition + 5
if xPosition > 747
xPosition = 747
endif
endif
`check for direction
if direction = 1
ballx = ballx + 6
bally = bally - 6
endif
if direction = 2
ballx = ballx + 6
bally = bally - 6
endif
if direction = 3
ballx = ballx + 6
bally = bally - 6
endif
if direction = 4
ballx = ballx + 6
bally = bally - 6
endif
if direction = 5
ballx = ballx + 6
bally = bally - 6
endif
if direction = 6
ballx = ballx + 6
bally = bally - 6
endif
if direction = 7
ballx = ballx + 6
bally = bally - 6
endif
if direction = 8
ballx = ballx + 6
bally = bally - 6
endif
`move the player
sprite 1, xPosition, yPosition, 1
`when the ball hits
hitbrick = sprite collision(3,0)
sprite 3, brickx, bricky, 1
delete sprite 3
sprite 2, brick1X, brick1Y, 1
`dying
if yposition < 21
play sound 2
sleep 2000
endif
`End game
dec lives
if lives <= 0
end
endif
`refresh the screen
sync
loop
Once run now, my first sound file plays, but also comes up with the error "runtime error at line 45. File does not exist" But at this line I have "sleep 4000" so i really don't understand.