Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

player rectangle not moving [duplicate]

$
0
0
import pygame# Initializationsgame = Truepygame.init()FPS = 30clock = pygame.time.Clock()# Screenscreen = pygame.display.set_mode((600,800))screen.fill((0,0,0))# PlayerpX = 300pY = 400pClr = ((255,255,255))def Player(plr):    pygame.draw.rect(screen, pClr, plr)while game:    player = pygame.Rect(pX,pY,25,25)    for event in pygame.event.get():        if event.type == pygame.QUIT:            game = False        if event.type == pygame.KEYDOWN:            while event.key == pygame.K_RIGHT:                pX -= 50    Player(player)    clock.tick(FPS)    pygame.display.update()

for some reason when I press the right key it doesn't move the player, but when printing it works just fine. sorry for asking this beginner question on here.

tried redrawing the player expecting it to move but no avail.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>