#๐Ÿ”’ can someone look over this and tell me what is wrong with it

56 messages ยท Page 1 of 1 (latest)

exotic flint
severe tangleBOT
#

@exotic flint

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

exotic rampart
#

whats wrong?

stiff plank
#

Does the call to update need to be in the main loop?

exotic rampart
#
    if key[pygame.k_a] == True:
           ^^^^^^^^^^
AttributeError: module 'pygame' has no attribute 'k_a'. Did you mean: 'K_a'?```
#

pygame.k_a -> pygame.K_a big K

exotic flint
#

yh i got that but the rectangle wont show

#

do you know why ??

exotic rampart
#

the update

stiff plank
exotic rampart
#

of the screen

exotic flint
#

how

#

??

exotic rampart
#

put it inside the loop

exotic flint
#

what loop

#

the wile loop

exotic rampart
#

gods loop

#

yes

exotic flint
#

but its in their

#

ohh no its not mb

#

actualy what one the player

#

or the draw one

exotic rampart
#

display update

#

i think

exotic flint
#

yh whats wrong with it

#

cause it was working fine

exotic rampart
#

rn what your code does

#

is move the rectangle

#

but never update

#

so it will show

#

only when u exit

#

the program

#

put it inside the while loop

exotic flint
#

wont show at all

exotic rampart
#

wdym

exotic flint
#

join voice chat 0

exotic rampart
#

show me code

exotic flint
#

i will screen share

exotic rampart
#
import pygame

pygame.init()

SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600

screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))

player = pygame.Rect((300 , 250, 50, 50))

run = True
while run == True:

    pygame.draw.rect(screen, (255, 0, 0),player)

    key = pygame.key.get_pressed()
    if key[pygame.K_a] == True:
        player.move_ip(-1, 0)
    elif key[pygame.K_d] == True:
        player.move_ip(1, 0)
    elif key[pygame.K_w] == True:
        player.move_ip(0, -1)
    elif key[pygame.K_s] == True:
        player.move_ip(0, 1)

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

    pygame.display.update()

pygame.quit()```
#

here bro

#

i think thats what u want ?

exotic flint
#

i dont under stand

exotic rampart
#

understand what

exotic flint
#

nvm i got it

#

thanks

#

im sorry fore being a hastle

exotic rampart
#
while True:
  .
  .
pygame.display.update()

______ THIS isnt same as ____
while True:
  .
  .
  pygame.display.update()
#

see im putting the display update inside the while loop

exotic flint
#

yh i got it thanks

exotic rampart
#

at the start of while loop

exotic flint
#

!close

severe tangleBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.