0

Help plz in this code why my rectangle is not moving help I am using pydroid 3 for this program help me how can I move my rectan

import pygame pygame.init() #screen screen_width = 900 screen_height = 600 screen = pygame.display.set_mode((screen_width,screen_height)) pygame.display.set_caption("Doraemon vs Gian") #colors white = (255,255,255) black = (0,0,0) #variables exit_game = False game_over = False clock = pygame.time.Clock() fps = 30 dora_x = 45 dora_y = 55 dora_size = 50 #game loop while not exit_game: for event in pygame.event.get(): if event.type == pygame.QUIT: exit_game = True if event.type == pygame.KEYDOWN: if event.key == pygame.K_6: dora_x = dora_x + 10 if event.key == pygame.K_4: dora_x = dora_x - 10 if event.key == pygame.K_8: dora_y = dora_y + 10 if event.key == pygame.K_2: dora_y = dora_y - 10 screen.fill(white) pygame.draw.rect(screen,black,[dora_x,dora_y,dora_size,dora_size]) pygame.display.update() clock.tick(fps) pygame.quit() quit()

15th Mar 2023, 12:21 PM
Balkishan Prajapati
Balkishan Prajapati - avatar
1 Respuesta
+ 1
I'm not sure on the particulars of the engine, but don't you have to repeat the screen wiping and drawing, with updated rectangle position?
15th Mar 2023, 12:56 PM
Ausgrindtube
Ausgrindtube - avatar