Error message

0 paul love · December 3, 2014
ive followed the tutorials on the snake game and i get this error, i cant see where im going
wrong as ive followed it to a tea...

the error im getting is expected an indented block?? here is code


if lead_x > randAppleX and lead_x < randAppleX + AppleThickness or lead_x + block_size > randAppleX and lead_x + block_size < randAppleX + AppleThickness:
            print("x crossover")
            if lead_y > randAppleY and lead_y < randAppleY + AppleThickness:




            clock.tick(FPS)    <<<<the error code highlighted this in red

            
    pygame.quit()
    quit()
    

gameLoop()

Post a Reply

Replies

Oldest  Newest  Rating
0 paul love · December 5, 2014
Ah right I see got it now thanks
0 Doug Fresh · December 4, 2014
Then you must have an indentation issue. It's hard to tell without seeing it in a code block. An indentation error, meaning after the if statement shown below, the code is not in at the proper indentation to be recognized. See Below
if lead_x > randAppleX and lead_x < randAppleX + AppleThickness or lead_x + block_size > randAppleX and lead_x + block_size < randAppleX + AppleThickness:
    print("x crossover")
    
if lead_y > randAppleY and lead_y < randAppleY + AppleThickness:
    clock.tick(FPS)

pygame.quit()
quit()


gameLoop()

Anytime you use an if, for or while statement, and the condition is true, it must have some code or function nested inside it. Otherwise the program will be  "stuck" in the statement. That's why you are getting an expected indentation block error. 
0 paul love · December 4, 2014
yes
0 Doug Fresh · December 4, 2014
did you assign a value to the Variable named FPS?
  • 1

Python

107,017 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator