Не двигается player на python
import pygame
from pygame.constants import QUIT
pygame.init()
HEIGHT = 800
WIDTH = 1200
COLOR_WHITE = (255, 255, 255)
COLOR_BLACK = (0, 0, 0)
main_display = pygame.display.set_mode((WIDTH, HEIGHT))
player_size = (30, 30)
player = pygame.Surface((player_size))
player.fill((COLOR_WHITE))
player_rect = player.get_rect()
player_speed = [1, 1]
main_display.blit(player, player_rect)
player_rect = player_rect.move(player_speed)
pygame.display.flip(COLOR_BLACK)
playing = True
while playing:
for event in pygame.event.get():
if event.type == QUIT:
playing = False
Ответы (1 шт):
Автор решения: Dendi
→ Ссылка
попробуй так:
import pygame
from pygame.constants import QUIT
pygame.init()
HEIGHT = 800
WIDTH = 1200
COLOR_WHITE = (255, 255, 255)
COLOR_BLACK = (0, 0, 0)
main_display = pygame.display.set_mode((WIDTH, HEIGHT))
player_size = (30, 30)
player = pygame.Surface(player_size)
player.fill(COLOR_WHITE)
player_rect = player.get_rect()
player_speed = [1, 1]
playing = True
while playing:
for event in pygame.event.get():
if event.type == QUIT:
playing = False
# Clear the screen
main_display.fill(COLOR_BLACK)
# Update player position
player_rect = player_rect.move(player_speed)
# Draw the player
main_display.blit(player, player_rect)
# Update the display
pygame.display.flip()
pygame.quit()