P
P
Phantomryt2020-02-17 10:02:40
Python
Phantomryt, 2020-02-17 10:02:40

AttributeError: module 'pygame' has no attribute 'display' What should I do?

import pygame


win = pygame.display.set_mode((500,500))


pygame.display.set_caption('Ghost house')

y=50
x = 50
widht = 40
height = 60
speed = 5

run = trye
while run:
    pygame.time.delay(500)

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False
    keys = pygame.key.get_pressed()
    if keys [pygame.K_LEFT]:
        x -= speed
    if keys [pygame.K_RIGHT]:
        x += speed
    if keys [pygame.K_UP]:
        y -= speed
    if keys [pygame.K_DOWN]:
        y += speed
    


            

    pygame.draw.rect(win, (0,255,0), (x,y,width,height))
    pygame.display.update

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Melnikov, 2020-02-17
@immelnikoff

Maybe display is a function? Then you need to call it as a function - display ().

R
Ruslan, 2020-02-17
@DollaR84

before working with any pygame objects, you first need to initialize it:
pygame.init()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question