Answer the question
In order to leave comments, you need to log in
Image not showing in pygame?
import image, no errors
import pygame
FPS = 60
W = 700 # ширина экрана
H = 300 # высота экрана
WHITE = (255, 255, 255)
LEFT="to the left"
RIGHT="to the right"
UP="to the up"
DOWN="to the down"
STOP="stop"
pygame.init()
sc = pygame.display.set_mode((W, H))
clock = pygame.time.Clock()
x = W // 2
y = H // 2
w=30
h=30
motion=STOP
image = pygame.image.load('C:\\Users\\Pavel\\Desktop\\game\\image.png').convert()
while 1:
sc.fill(WHITE)
pygame.display.update()
for i in pygame.event.get():
sc.blit(image, [x, y])
if i.type == pygame.QUIT:
exit()
elif y==0:
y=1
elif i.type == pygame.KEYDOWN:
if i.key == pygame.K_LEFT:
motion=LEFT
elif i.key == pygame.K_RIGHT:
motion=RIGHT
elif i.key == pygame.K_DOWN:
motion=DOWN
elif i.key == pygame.K_UP:
motion=UP
elif i.mod == pygame.KMOD_LSHIFT:
y+=50
if motion==LEFT:
x-=3
elif motion==RIGHT:
x+=3
elif motion==UP:
y-=3
elif motion==DOWN:
y+=3
pygame.time.delay(60)
pygame.display.flip()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question