PyGame не отображает поверхность. Здравствуйте, я начал изучать PyGame и столкнулся с проблемой: холст не отображается в окне. Я ещё новичок в этой теме, возможна ошибка о . Вот код:
import pygame
width = 350
height = 500
FPS = 30
pygame.init()
screen = pygame.display.set_mode((height, width))
pygame.display.set_caption('Title')
clock = pygame.time.Clock()
class Circle(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.Surface((40, 40))
self.rect = self.image.get_rect()
self.rect.x = width - 40
self.rect.y = height - 40
self.speedx = -8
def update(self):
self.rect.x += self.speedx / FPS
if self.rect.centerx == self.image.get_width() - 20:
self.speedx = 0
self.rect.x = 0
circle = Circle()
running = True
while running:
clock.tick(FPS)
# Enter
# Update
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
circle.update()
# Painting
screen.fill((0, 0, 0))
pygame.draw.circle(circle.image, (0, 255, 0), (circle.rect.centerx, circle.rect.centery), 20)
screen.blit(circle.image, (circle.image.get_width(), circle.image.get_height()))
pygame.display.flip()
pygame.quit()
P.s. На экране справа налево должен двигаться зелёный круг, у левого края он должен останавливаться.
function preobr(s:string):string;var i,j,p,n,sered:integer; gl,zp,slovo:string; m:array [1..80] of string;beginzp:='!?*,.'; gl:='аоуыэяеёюи'; p:=pos(' ',s); i:=0; repeat inc(i); slovo:=copy(s,1,p-1); m[i]:=slovo; delete(s,1,p); p:=pos(' ',s); until p=0; n:=i+1; m[n]:=s; for i:=1 to n do begin s:=m[i]; if pos(s[length(s)],zp)<>0 then p:=length(s)-1 else p:=length(s); sered:=(p div 2)+1; if (not odd(p)) or (p<3) then continue; if pos(s[1],gl)=0 then continue; if pos(s[sered],gl)=0 then continue; if pos(s[p],gl)=0 then continue; s[1]:=UpCase(s[1]); s[sered]:=UpCase(s[sered]); s[p]:=UpCase(s[p]); m[i]:=s+'('+s[1]+','+s[sered]+','+s[p]+')'; end; s:=''; for i:=1 to n do s:=s+m[i]+' '; preobr:=s;end;
beginassign(f,'input.txt'); reset(f);assign(t,'output.txt'); rewrite(t); while not eof(f) do begin readln(f,s); writeln(t, preobr(s) ); end; writeln('Файл успешно записан...'); close(f);close(t);readln;end.