Знайомимося з pygame zero в єpython

59 подписчиков

12+
12+

3 просмотра

16 дней назад

ПожаловатьсяНарушение авторских прав

59 подписчиков

12+
12+

3 просмотра

16 дней назад

ПожаловатьсяНарушение авторских прав
12+
12+

3 просмотра

16 дней назад

https://yepython.pp.ua/ import pgzrun import random WIDTH = 800 HEIGHT = 800 score = 0 paddle = Rect((250, 700), (50, 50)) # position size rect1 = Rect((400, 400), (100, 50)) rect2 = Rect((100, 700), (80, 80)) # position size speed = 1 collision = False collision1 = False def update(): global collision global collision1 global score if keyboard.left: paddle.x -= speed if keyboard.right: paddle.x += speed if keyboard.up: paddle.y -= speed if keyboard.down: paddle.y += speed collision = paddle.colliderect(rect1) collision1 = paddle.colliderect(rect2) if collision: rect1.x = random.randint(0, WIDTH - 100) rect1.y = random.randint(0, HEIGHT - 100) score += 1 if collision1: rect2.x = random.randint(0, WIDTH - 100) rect2.y = random.randint(0, HEIGHT - 100) score -= 1 def draw(): global score screen.clear() screen.fill((100, 80, 100)) screen.draw.filled_rect(paddle, "blue") screen.draw.filled_rect(rect1, "red") screen.draw.filled_rect(rect2, "white") screen.draw.text( f"Score: {score}", (10, 10), color="lightgreen", fontsize=36 ) pgzrun.go()

Название:

Знайомимося з pygame zero в єpython

Категория:

Разное