#๐ can someone look over this and tell me what is wrong with it
56 messages ยท Page 1 of 1 (latest)
@exotic flint
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.
whats wrong?
? What's the problem? What are you asking about?
Does the call to update need to be in the main loop?
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

the update
of the screen
put it inside the loop
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
wont show at all
wdym
join voice chat 0
show me code
i will screen share
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 ?
i dont under stand
understand what
while True:
.
.
pygame.display.update()
______ THIS isnt same as ____
while True:
.
.
pygame.display.update()
see im putting the display update inside the while loop
yh i got it thanks
i think u need a screen.fill((0,0,0))
at the start of while loop
!close
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.