{"id":396099,"date":"2024-06-29T12:38:03","date_gmt":"2024-06-29T12:38:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=396099"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-29T12:38:03","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=396099","title":{"rendered":"<span>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Pygame \/ \u0427\u0430\u0441\u0442\u044c 2. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u043c\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Pygame \/ \u0427\u0430\u0441\u0442\u044c 2. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u043c\u0438<\/h2>\n<p>\u0412\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0435\u0440\u0438\u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432 \u00ab<code>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u0433\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Pygame<\/code>\u00bb. \u041e\u043d\u0430 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043d\u044b \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438\u0433\u0440 \u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043d\u0430\u0432\u044b\u043a\u043e\u0432 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 Python. \u041d\u0430\u0447\u0430\u0442\u044c \u0441\u0442\u043e\u0438\u0442 \u0441 \u0443\u0440\u043e\u043a\u0430: \u00ab<code>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Pygame \/ \u0427\u0430\u0441\u0442\u044c 1. \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/code>\u00bb.<\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0441\u043f\u0440\u0430\u0439\u0442?<\/h3>\n<p>\u0421\u043f\u0440\u0430\u0439\u0442 \u2014 \u044d\u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0439 \u0433\u0440\u0430\u0444\u0438\u043a\u0438, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f. \u0412 \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u043e\u0439 \u0438\u0433\u0440\u0435 \u0432\u0441\u0435, \u0447\u0442\u043e \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u043c\u0438. \u0421\u043f\u0440\u0430\u0439\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043c\u0438 \u0438\u0433\u0440\u043e\u043a\u0443.<\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u0432 \u0441\u043b\u0443\u0447\u0430\u0439 \u044d\u0442\u043e\u0439 \u0438\u0433\u0440\u044b \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044b \u201c\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u201d \u0438 \u201c\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u201d \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430. \u041d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 \u0438\u0433\u0440\u0435 \u043c\u043d\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432, \u0442\u043e \u0446\u0438\u043a\u043b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0442\u0430\u043d\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u044b\u043c. \u0412 Pygame \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435: \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432.<\/p>\n<p>\u041d\u0430\u0431\u043e\u0440 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u2014 \u044d\u0442\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e. \u0412\u043e\u0442 \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u0443 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u0432 \u0438\u0433\u0440\u0435:<\/p>\n<pre><code>clock = pygame.time.Clock() all_sprites = pygame.sprite.Group()  <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0433\u0440\u0443\u043f\u043f\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u0432 \u0446\u0438\u043a\u043b:<\/p>\n<pre><code>    # \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435     all_sprites.update()  &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; padding-left: 0px; color: rgb(243, 228, 203);\" class=\"token comment\"># \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430&lt;\/span> screen&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>fill&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">(&lt;\/span>BLACK&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">)&lt;\/span> all_sprites&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>draw&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">(&lt;\/span>screen&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">)&lt;\/span>  <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432 \u0433\u0440\u0443\u043f\u043f\u0443\u00a0<code>all_sprites<\/code>. \u0422\u0430\u043a\u043e\u0439 \u0441\u043f\u0440\u0430\u0439\u0442 \u0431\u0443\u0434\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u043d \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u0446\u0438\u043a\u043b\u0435.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043f\u0440\u0430\u0439\u0442\u0430<\/h3>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430. \u0412 Pygame \u0432\u0441\u0435 \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u044e\u0442\u00a0<a href=\"https:\/\/pythonru.com\/primery\/primery-raboty-s-klassami-v-python\" rel=\"noopener noreferrer nofollow\"><strong>\u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438<\/strong><\/a>. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 \u044d\u0442\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Python, \u0442\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u0434\u0430 \u0432 \u0435\u0434\u0438\u043d\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c. \u041f\u043e\u043d\u0430\u0447\u0430\u043b\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0443\u0442\u0430\u0442\u044c, \u043d\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u044b Pygame \u2014 \u043e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0438 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430:<\/p>\n<pre><code>class Player(pygame.sprite.Sprite): <\/code><\/pre>\n<p><code>class<\/code>\u00a0\u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 Python, \u0447\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u043c \u0438\u0433\u0440\u043e\u043a\u0430. \u0415\u0433\u043e \u0442\u0438\u043f\u00a0<code>pygame.sprite.Sprite<\/code>. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u0432 Pygame \u043a\u043b\u0430\u0441\u0441\u0435\u00a0<code>Sprite<\/code>.<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438\u00a0<code>class<\/code>\u00a0\u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<code>init()<\/code>, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0430\u044f \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0422\u0430\u043a\u0436\u0435 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0432 Pygame \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0434\u0432\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430:\u00a0<code>image<\/code>\u00a0\u0438\u00a0<code>rect<\/code>.<\/p>\n<pre><code>class Player(pygame.sprite.Sprite):     def init(self):         pygame.sprite.Sprite.init(self)         self.image = pygame.Surface((50, 50))         self.image.fill(GREEN)         self.rect = self.image.get_rect()<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430,\u00a0<code>Pygame.sprite.Sprite.__init__(self)<\/code>\u00a0\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432 Pygame \u2014 \u043e\u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432\u00a0<code>Sprite<\/code>. \u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u00a0<code>image<\/code>. \u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 50\u044550 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0435\u0433\u043e \u0437\u0435\u043b\u0435\u043d\u044b\u043c (<code>GREEN<\/code>) \u0446\u0432\u0435\u0442\u043e\u043c. \u0427\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c\u00a0<code>image<\/code>\u00a0\u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u043a\u0440\u0430\u0441\u0438\u0432\u0435\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436\u0430 \u0438\u043b\u0438 \u043a\u043e\u0441\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u0440\u0430\u0431\u043b\u044c, \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043f\u043b\u043e\u0448\u043d\u043e\u0433\u043e \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430.<\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u00a0<code>rect<\/code>\u00a0\u0441\u043f\u0440\u0430\u0439\u0442\u0430. \u042d\u0442\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u043e\u0435 \u043e\u0442\u00a0<code>rectangle<\/code>\u00a0(\u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a). \u041f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438 \u043f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 Pygame \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041a\u043e\u043c\u0430\u043d\u0434\u0430\u00a0<code>get_rect()<\/code>\u00a0\u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u00a0<code>image<\/code>\u00a0\u0438 \u0432\u044b\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0439 \u043e\u043a\u0440\u0443\u0436\u0438\u0442\u044c \u0435\u0433\u043e.<\/p>\n<p><code>rect<\/code>\u00a0\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443:<\/p>\n<pre><code>class Player(pygame.sprite.Sprite):     def __init__(self):         pygame.sprite.Sprite.__init__(self)         self.image = pygame.Surface((50, 50))         self.image.fill(GREEN)         self.rect = self.image.get_rect()         self.rect.center = (WIDTH \/ 2, HEIGHT \/ 2) <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0438\u0433\u0440\u043e\u043a\u0430 Player, \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c (\u0441\u043e\u0437\u0434\u0430\u0442\u044c) \u0435\u0433\u043e, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 (instance) \u043a\u043b\u0430\u0441\u0441\u0430 Player. \u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043f\u0440\u0430\u0439\u0442 \u0432 \u0433\u0440\u0443\u043f\u043f\u0443\u00a0<code>all_sprites<\/code>.<\/p>\n<pre><code>all_sprites = pygame.sprite.Group() player = Player() all_sprites.add(player) <\/code><\/pre>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443 \u043e\u043a\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0437\u0435\u043b\u0435\u043d\u044b\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442. \u0423\u0432\u0435\u043b\u0438\u0447\u044c\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u00a0<code>WIDTH<\/code>\u00a0\u0438\u00a0<code>HEIGHT<\/code>\u00a0\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0448\u0430\u0433\u0435.<\/p>\n<h3>\u0414\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0441\u043f\u0440\u0430\u0439\u0442\u0430<\/h3>\n<p>\u0412 \u0438\u0433\u0440\u043e\u0432\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<code>all_sprites.update()<\/code>. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0432 \u0433\u0440\u0443\u043f\u043f\u0435 Pygame \u0438\u0449\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e\u00a0<code>update()<\/code>\u00a0\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0435\u0435. \u0427\u0442\u043e\u0431\u044b \u0441\u043f\u0440\u0430\u0439\u0442 \u0434\u0432\u0438\u0433\u0430\u043b\u0441\u044f, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>class Player(pygame.sprite.Sprite):     def __init__(self):         pygame.sprite.Sprite.__init__(self)         self.image = pygame.Surface((50, 50))         self.image.fill(GREEN)         self.rect = self.image.get_rect()         self.rect.center = (WIDTH \/ 2, HEIGHT \/ 2)  &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(128, 255, 255);\" class=\"token keyword keyword-def\">def&lt;\/span> &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 128, 176);\" class=\"token function\">update&lt;\/span>&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">(&lt;\/span>self&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">)&lt;\/span>&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">:&lt;\/span>     self&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>rect&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>x &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 222, 164);\" class=\"token operator\">+=&lt;\/span> &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 148, 255);\" class=\"token number\">5&lt;\/span>  <\/code><\/pre>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0433\u0440\u043e\u0432\u043e\u043c \u0446\u0438\u043a\u043b\u0435 x-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 5 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u043e\u043d \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u044d\u043a\u0440\u0430\u043d\u0430, \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u044f \u043f\u0440\u0430\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b.<\/p>\n<p>\u0418\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e, \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0432 \u0441\u043f\u0440\u0430\u0439\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043a\u0440\u0443\u0433\u0443 \u2014 \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0434\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0434\u043e \u043f\u0440\u0430\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u044d\u043a\u0440\u0430\u043d\u0430, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u0435\u0433\u043e \u0432\u043b\u0435\u0432\u043e. \u042d\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u00a0<code>rect<\/code>\u00a0\u0441\u043f\u0440\u0430\u0439\u0442\u0430:<img loading=\"lazy\" decoding=\"async\" inline=\"true\" class=\"image image-inline\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/18e\/5a2\/2ce\/18e5a22ceaa80a555525474165b6ee4a.png\" width=\"1146\" height=\"818\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/18e\/5a2\/2ce\/18e5a22ceaa80a555525474165b6ee4a.png\"\/><\/p>\n<p>\u0422\u0430\u043a, \u0435\u0441\u043b\u0438 \u043b\u0435\u0432\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u0430\u00a0<code>rect<\/code>\u00a0\u043f\u0440\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u044d\u043a\u0440\u0430\u043d\u0430, \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0434\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u043e\u0433\u043e \u043a\u0440\u0430\u044f \u0440\u0430\u0432\u043d\u043e\u0435 0:<\/p>\n<pre><code>class Player(pygame.sprite.Sprite):     def __init__(self):         pygame.sprite.Sprite.__init__(self)         self.image = pygame.Surface((50, 50))         self.image.fill(GREEN)         self.rect = self.image.get_rect()         self.rect.center = (WIDTH \/ 2, HEIGHT \/ 2)  &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(128, 255, 255);\" class=\"token keyword keyword-def\">def&lt;\/span> &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 128, 176);\" class=\"token function\">update&lt;\/span>&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">(&lt;\/span>self&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">)&lt;\/span>&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">:&lt;\/span>     self&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>rect&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>x &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 222, 164);\" class=\"token operator\">+=&lt;\/span> &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 148, 255);\" class=\"token number\">5&lt;\/span>     &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(128, 255, 255);\" class=\"token keyword keyword-if\">if&lt;\/span> self&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>rect&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>left &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 222, 164);\" class=\"token operator\">&amp;gt;&lt;\/span> WIDTH&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">:&lt;\/span>         self&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>rect&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>right &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 222, 164);\" class=\"token operator\">=&lt;\/span> &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 148, 255);\" class=\"token number\">0&lt;\/span>  <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a \u0441\u043f\u0440\u0430\u0439\u0442 \u0431\u0443\u0434\u0442\u043e \u0431\u044b \u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u043a\u0440\u0443\u0433\u0443.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0439\u0442\u0435\u0441\u044c \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u0432\u0441\u0435, \u0447\u0442\u043e \u0432\u044b \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0435 \u0432 \u043c\u0435\u0442\u043e\u0434\u00a0<code>update()<\/code>, \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u0430\u0434\u0440\u0435. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0440\u0430\u0439\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437 (\u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443\u00a0<code>y<\/code>) \u0438\u043b\u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0441\u0442\u0435\u043d (\u0438\u0437\u043c\u0435\u043d\u044f\u044f \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u043e \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u043a\u0440\u0430\u044f).<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/588765\/\"> https:\/\/habr.com\/ru\/articles\/588765\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Pygame \/ \u0427\u0430\u0441\u0442\u044c 2. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u043c\u0438<\/h2>\n<p>\u0412\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0435\u0440\u0438\u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432 \u00ab<code>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u0433\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Pygame<\/code>\u00bb. \u041e\u043d\u0430 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043d\u044b \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438\u0433\u0440 \u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043d\u0430\u0432\u044b\u043a\u043e\u0432 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 Python. \u041d\u0430\u0447\u0430\u0442\u044c \u0441\u0442\u043e\u0438\u0442 \u0441 \u0443\u0440\u043e\u043a\u0430: \u00ab<code>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Pygame \/ \u0427\u0430\u0441\u0442\u044c 1. \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/code>\u00bb.<\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0441\u043f\u0440\u0430\u0439\u0442?<\/h3>\n<p>\u0421\u043f\u0440\u0430\u0439\u0442 \u2014 \u044d\u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0439 \u0433\u0440\u0430\u0444\u0438\u043a\u0438, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f. \u0412 \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u043e\u0439 \u0438\u0433\u0440\u0435 \u0432\u0441\u0435, \u0447\u0442\u043e \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u043c\u0438. \u0421\u043f\u0440\u0430\u0439\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043c\u0438 \u0438\u0433\u0440\u043e\u043a\u0443.<\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u0432 \u0441\u043b\u0443\u0447\u0430\u0439 \u044d\u0442\u043e\u0439 \u0438\u0433\u0440\u044b \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044b \u201c\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u201d \u0438 \u201c\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u201d \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430. \u041d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 \u0438\u0433\u0440\u0435 \u043c\u043d\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432, \u0442\u043e \u0446\u0438\u043a\u043b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0442\u0430\u043d\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u044b\u043c. \u0412 Pygame \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435: \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432.<\/p>\n<p>\u041d\u0430\u0431\u043e\u0440 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u2014 \u044d\u0442\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e. \u0412\u043e\u0442 \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u0443 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u0432 \u0438\u0433\u0440\u0435:<\/p>\n<pre><code>clock = pygame.time.Clock() all_sprites = pygame.sprite.Group()  <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0433\u0440\u0443\u043f\u043f\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u0432 \u0446\u0438\u043a\u043b:<\/p>\n<pre><code>    # \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435     all_sprites.update()  &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; padding-left: 0px; color: rgb(243, 228, 203);\" class=\"token comment\"># \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430&lt;\/span> screen&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>fill&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">(&lt;\/span>BLACK&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">)&lt;\/span> all_sprites&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>draw&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">(&lt;\/span>screen&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">)&lt;\/span>  <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432 \u0433\u0440\u0443\u043f\u043f\u0443\u00a0<code>all_sprites<\/code>. \u0422\u0430\u043a\u043e\u0439 \u0441\u043f\u0440\u0430\u0439\u0442 \u0431\u0443\u0434\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u043d \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u0446\u0438\u043a\u043b\u0435.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043f\u0440\u0430\u0439\u0442\u0430<\/h3>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430. \u0412 Pygame \u0432\u0441\u0435 \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u044e\u0442\u00a0<a href=\"https:\/\/pythonru.com\/primery\/primery-raboty-s-klassami-v-python\" rel=\"noopener noreferrer nofollow\"><strong>\u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438<\/strong><\/a>. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 \u044d\u0442\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Python, \u0442\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u0434\u0430 \u0432 \u0435\u0434\u0438\u043d\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c. \u041f\u043e\u043d\u0430\u0447\u0430\u043b\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0443\u0442\u0430\u0442\u044c, \u043d\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u044b Pygame \u2014 \u043e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0438 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430:<\/p>\n<pre><code>class Player(pygame.sprite.Sprite): <\/code><\/pre>\n<p><code>class<\/code>\u00a0\u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 Python, \u0447\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u043c \u0438\u0433\u0440\u043e\u043a\u0430. \u0415\u0433\u043e \u0442\u0438\u043f\u00a0<code>pygame.sprite.Sprite<\/code>. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u0432 Pygame \u043a\u043b\u0430\u0441\u0441\u0435\u00a0<code>Sprite<\/code>.<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438\u00a0<code>class<\/code>\u00a0\u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<code>init()<\/code>, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0430\u044f \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0422\u0430\u043a\u0436\u0435 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0432 Pygame \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0434\u0432\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430:\u00a0<code>image<\/code>\u00a0\u0438\u00a0<code>rect<\/code>.<\/p>\n<pre><code>class Player(pygame.sprite.Sprite):     def init(self):         pygame.sprite.Sprite.init(self)         self.image = pygame.Surface((50, 50))         self.image.fill(GREEN)         self.rect = self.image.get_rect()<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430,\u00a0<code>Pygame.sprite.Sprite.__init__(self)<\/code>\u00a0\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432 Pygame \u2014 \u043e\u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432\u00a0<code>Sprite<\/code>. \u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u00a0<code>image<\/code>. \u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 50\u044550 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0435\u0433\u043e \u0437\u0435\u043b\u0435\u043d\u044b\u043c (<code>GREEN<\/code>) \u0446\u0432\u0435\u0442\u043e\u043c. \u0427\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c\u00a0<code>image<\/code>\u00a0\u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u043a\u0440\u0430\u0441\u0438\u0432\u0435\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436\u0430 \u0438\u043b\u0438 \u043a\u043e\u0441\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u0440\u0430\u0431\u043b\u044c, \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043f\u043b\u043e\u0448\u043d\u043e\u0433\u043e \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430.<\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u00a0<code>rect<\/code>\u00a0\u0441\u043f\u0440\u0430\u0439\u0442\u0430. \u042d\u0442\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u043e\u0435 \u043e\u0442\u00a0<code>rectangle<\/code>\u00a0(\u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a). \u041f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438 \u043f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 Pygame \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041a\u043e\u043c\u0430\u043d\u0434\u0430\u00a0<code>get_rect()<\/code>\u00a0\u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u00a0<code>image<\/code>\u00a0\u0438 \u0432\u044b\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0439 \u043e\u043a\u0440\u0443\u0436\u0438\u0442\u044c \u0435\u0433\u043e.<\/p>\n<p><code>rect<\/code>\u00a0\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443:<\/p>\n<pre><code>class Player(pygame.sprite.Sprite):     def __init__(self):         pygame.sprite.Sprite.__init__(self)         self.image = pygame.Surface((50, 50))         self.image.fill(GREEN)         self.rect = self.image.get_rect()         self.rect.center = (WIDTH \/ 2, HEIGHT \/ 2) <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0438\u0433\u0440\u043e\u043a\u0430 Player, \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c (\u0441\u043e\u0437\u0434\u0430\u0442\u044c) \u0435\u0433\u043e, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 (instance) \u043a\u043b\u0430\u0441\u0441\u0430 Player. \u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043f\u0440\u0430\u0439\u0442 \u0432 \u0433\u0440\u0443\u043f\u043f\u0443\u00a0<code>all_sprites<\/code>.<\/p>\n<pre><code>all_sprites = pygame.sprite.Group() player = Player() all_sprites.add(player) <\/code><\/pre>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443 \u043e\u043a\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0437\u0435\u043b\u0435\u043d\u044b\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442. \u0423\u0432\u0435\u043b\u0438\u0447\u044c\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u00a0<code>WIDTH<\/code>\u00a0\u0438\u00a0<code>HEIGHT<\/code>\u00a0\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0448\u0430\u0433\u0435.<\/p>\n<h3>\u0414\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0441\u043f\u0440\u0430\u0439\u0442\u0430<\/h3>\n<p>\u0412 \u0438\u0433\u0440\u043e\u0432\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<code>all_sprites.update()<\/code>. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0432 \u0433\u0440\u0443\u043f\u043f\u0435 Pygame \u0438\u0449\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e\u00a0<code>update()<\/code>\u00a0\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0435\u0435. \u0427\u0442\u043e\u0431\u044b \u0441\u043f\u0440\u0430\u0439\u0442 \u0434\u0432\u0438\u0433\u0430\u043b\u0441\u044f, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>class Player(pygame.sprite.Sprite):     def __init__(self):         pygame.sprite.Sprite.__init__(self)         self.image = pygame.Surface((50, 50))         self.image.fill(GREEN)         self.rect = self.image.get_rect()         self.rect.center = (WIDTH \/ 2, HEIGHT \/ 2)  &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(128, 255, 255);\" class=\"token keyword keyword-def\">def&lt;\/span> &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 128, 176);\" class=\"token function\">update&lt;\/span>&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">(&lt;\/span>self&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">)&lt;\/span>&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">:&lt;\/span>     self&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>rect&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>x &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 222, 164);\" class=\"token operator\">+=&lt;\/span> &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 148, 255);\" class=\"token number\">5&lt;\/span>  <\/code><\/pre>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0433\u0440\u043e\u0432\u043e\u043c \u0446\u0438\u043a\u043b\u0435 x-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 5 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u043e\u043d \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u044d\u043a\u0440\u0430\u043d\u0430, \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u044f \u043f\u0440\u0430\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b.<\/p>\n<p>\u0418\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e, \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0432 \u0441\u043f\u0440\u0430\u0439\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043a\u0440\u0443\u0433\u0443 \u2014 \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0434\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0434\u043e \u043f\u0440\u0430\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u044d\u043a\u0440\u0430\u043d\u0430, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u0435\u0433\u043e \u0432\u043b\u0435\u0432\u043e. \u042d\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u00a0<code>rect<\/code>\u00a0\u0441\u043f\u0440\u0430\u0439\u0442\u0430:<\/p>\n<p>\u0422\u0430\u043a, \u0435\u0441\u043b\u0438 \u043b\u0435\u0432\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u0430\u00a0<code>rect<\/code>\u00a0\u043f\u0440\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u044d\u043a\u0440\u0430\u043d\u0430, \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0434\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u043e\u0433\u043e \u043a\u0440\u0430\u044f \u0440\u0430\u0432\u043d\u043e\u0435 0:<\/p>\n<pre><code>class Player(pygame.sprite.Sprite):     def __init__(self):         pygame.sprite.Sprite.__init__(self)         self.image = pygame.Surface((50, 50))         self.image.fill(GREEN)         self.rect = self.image.get_rect()         self.rect.center = (WIDTH \/ 2, HEIGHT \/ 2)  &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(128, 255, 255);\" class=\"token keyword keyword-def\">def&lt;\/span> &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 128, 176);\" class=\"token function\">update&lt;\/span>&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">(&lt;\/span>self&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">)&lt;\/span>&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">:&lt;\/span>     self&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>rect&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>x &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 222, 164);\" class=\"token operator\">+=&lt;\/span> &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 148, 255);\" class=\"token number\">5&lt;\/span>     &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(128, 255, 255);\" class=\"token keyword keyword-if\">if&lt;\/span> self&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>rect&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token punctuation\">.&lt;\/span>left &lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 222, 164);\" class=\"token operator\">&amp;gt;&lt;\/span> WIDTH&lt;span style=\"box-sizing: border-box; font-weight: inherit !important; font-size: inherit; color: rgb(255, 255, 238);\" class=\"token<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-396099","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/396099","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=396099"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/396099\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=396099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=396099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=396099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}