I keep getting this error and I do not know how to fix it, I can link all the files for the code within the link and I'll put the code in the description. Link - https://drive.google.com/drive/folders/1aIEG-TE2txwnEl93j82PdcG7d9aTCxVP?usp=sharing
# Importing all necessary scripts
import pygame
import time
import sys
# Initiating pygame
pygame.init()
# Creating colours for the game which will be needed
transparent = (0, 0, 0, 0)
# Creating the fonts for the game
Menufont = pygame.font.SysFont('Bahnschrift SemiBold', 70)
SmallMenufont = pygame.font.SysFont('Banschrift SemiBold', 20)
# Creating the window for where the game is able to be played
screen = pygame.display.set_mode((1280, 720))
# Getting the height and the width of the screen into a variable
width = screen.get_width()
height = screen.get_height()
time.sleep(0.1)
# Creating a Procedure for the Main Menu
def MainMenu():
# Creating the main menu with a background image which has been modified to provide
background = pygame.image.load('Main Menu Background.png')
screen.blit(background, (0, 0))
# Creating text for the buttons for the main menu of the game
PlaySolo_text = Menufont.render("Play Solo", True, (3, 3, 116))
PlayMulti_text = Menufont.render("Play Multi", True, (3, 3, 116))
Leaders_text = Menufont.render("Leaders", True, (3, 3, 116))
Credits_text = Menufont.render("Credits", True, (3, 3, 116))
Options_text = Menufont.render("Options", True, (3, 3, 116))
Exit_text = Menufont.render("Exit", True, (3, 3, 116))
# Placing the text for the buttons onto the main menu for the game
screen.blit(PlaySolo_text, (229, 221))
screen.blit(PlayMulti_text, (833, 221))
screen.blit(Leaders_text, (243, 359))
screen.blit(Credits_text, (863, 359))
screen.blit(Options_text, (241, 492))
screen.blit(Exit_text, (906, 492))
# Updating the menu for the game
pygame.display.update()
# This makes it so the cross in the corner is able to work
Running = True
while Running == True:
# Provides information whilst the programme is running
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONUP:
# This gets the x and y co-ordinates for where the mouse is
mouse = pygame.mouse.get_pos()
print(mouse)
# If the user presses the Play Solo Button
if mouse[0] > 221 and mouse[0] < 454 and mouse[1] > 199 and mouse[1] < 289:
print("Play Solo")
# If the user presses the Play Multi Button
elif mouse[0] > 832 and mouse[0] < 1067 and mouse[1] > 199 and mouse[1] < 289:
print("Play Multi")
# If the user presses the Leaders Button
elif mouse[0] > 221 and mouse[0] < 454 and mouse[1] > 338 and mouse[1] < 428:
print("Leaders")
# If the user presses the Credits Button
elif mouse[0] > 832 and mouse[0] < 1067 and mouse[1] > 338 and mouse[1] < 428:
# Makes the background invisible which allows another image to appear behind it
background.fill(transparent)
screen.blit(background, (0, 0))
pygame.display.update()
# This goes to the Credits Procedure
Credits()
# If the user presses the Options button
elif mouse[0] > 221 and mouse[0] < 451 and mouse[1] > 468 and mouse[1] < 561:
print("Options")
# If the user presses the Exit Button
elif mouse[0] > 832 and mouse[0] < 1067 and mouse[1] > 468 and mouse[1] < 561:
# Makes the application close
Running = False
if event.type == pygame.QUIT:
Running = False
def Credits():
# Adding the Credits Background onto the screen
background = pygame.image.load('Credits Background.png')
screen.blit(background, (0, 0))
# Opening the text file so that it can be put onto the screen
CreditFile = open("Credits.txt", "r")
CreditFileText = CreditFile.read()
LineCount = len(open("Credits.txt").readlines())
for i in range(1, LineCount):
# Putting the text onto the screen so that it can be read
Text = open("Credits.txt").readlines(i)
CreditText = SmallMenufont.render(Text, True, (238, 238, 238))
screen.blit(CreditText, (0, 0))
# Updates the screen so everything will appear
pygame.display.update()
# This makes it so the cross in the corner is able to work
Running = True
while Running == True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
Running = False
MainMenu()
I am trying to make it so that the each line within the text file of the credits goes to a new line within the credits menu, however the credits menu does not load and it gives the error which I cannot understand