I'm getting errors about pygame modules, but have no clue why it is happening. I haven no files/folders named pygame

checking for pygame file and folder

#Initialisation
import pygame
import random
from pygame.locals import *
pygame.init()

root = pygame.display.set_mode((1024,720))
pygame.display.set_caption("Tron Racer!")

clock = pygame.time.Clock()



#Defining Game Menu
#def game_menu():
  #  intro = True
  #  while intro:
   #     for event in pygame.event.get():
   #         if event.type = pygame.QUIT;
   #         pygame.quit()
   #         quit()
  #  gameDisplay.fill(0, 0, 0)
#Defining the intial values of the Bike(s)
class player(object):
    def __init__(self, x, y, width, height):
        self.x = x
        self.y = y
        self.width = width
        self.height = height

        self.vel = 5
        self.lives = 3

class trail(object):
    def __init__(self, x, y, width, height):
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.vel = 5

#Drawing for Animation
def draw(root):
    return 

#Game Loop
Bike1 = player(300, 410, 32, 32)
Bike2 = player(200, 310, 32, 32)
BikeTrail1 = trail(Bike1.x, Bike1.y, 12, 12)
run = True
while run:
    pygame.time.delay(100)
    clock.tick(27)

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False

    keys = pygame.key.get_pressed()
#Bike 1 
    events = pygame.event.get()
    for event in events:


        if event.type == pygame.KEYDOWN:
            if event.key == chr('K_a') and Bike1.x > 0:
                    Bike1.x -= Bike1.vel   #Vel to chance ONE value rather than four
                    Bike1.left = True
                    Bike1.right = False

            if event.type == pygame.KEYDOWN:
                if event.key == chr('K_d') and Bike1.x < 1024 - Bike1.width:
                    Bike1.x += Bike1.vel
                    Bike1.left = False
                    Bike1.right = True

            if event.type == pygame.KEYDOWN:
                if event.key == chr('K_w') and Bike1.y > 0 + Bike1.height - Bike1.vel:
                    Bike1.y -= Bike1.vel

            if event.type == pygame.KEYDOWN:
                if event.key == chr('K_s') and Bike1.x < 0 :
                    Bike1.y += Bike1.vel


#Bike 2
    event = pygame.event.get()
    for event in events:
            if event.type == pygame.KEYDOWN:
                if event.key == chr('K_LEFT')and Bike1.x > 0:
                    Bike1.x -= Bike1.vel   #Vel to chance ONE value rather than four
                    Bike1.left = True
                    Bike1.right = False

            if event.type == pygame.KEYDOWN:
                if event.key == chr('K_RIGHT') and Bike1.x < 1024 - Bike1.width:
                    Bike1.x += Bike1.vel
                    Bike1.left = False
                    Bike1.right = True

            if event.type == pygame.KEYDOWN:
                if event.key == chr('K_UP') and Bike1.y > 0 + Bike1.height - Bike1.vel:
                    Bike1.y -= Bike1.vel

            if event.type == pygame.KEYDOWN:
                if event.key == chr('K_DOWN') and Bike1.y > 0 + Bike1.height - Bike1.vel:
                    Bike1.y += Bike1.vel
#----------------------------------------------------------------------


#Draws // Updates the game
#game_menu()
root.fill((0, 0, 0))
pygame.draw.rect(root, (255, 0, 0), (Bike1.x, Bike1.y, Bike1.width, Bike1.height))
pygame.draw.rect(root, (0, 255, 0), (Bike2.x, Bike2.y, Bike2.width, Bike2.height))
pygame.display.update()

pygame.quit()

errors

https://cdn.discordapp.com/attachments/336426882088042502/577406886446497792/123123123.PNG

The game should run and work.

Sorry my english isnt greatest.

Thank you

0 Answers