, как сделать так, чтобы монетки собирались и был счёт? import play
import pygame

fon = play.new_image(image="fon.png", size=150)
ball = play.new_circle(color ="red", radius=20, border_color="green", border_width=2, x=0, y=-250)
finish = play.new_text(words="Finish", font_size=40, color="orange")
finish.top = play.screen.top

walls = [play.new_box(color = "yellow", width=200, height=10, x=-100, y=-200),
play.new_box(color = "yellow", width=200, height=10, x=150, y=-220),
play.new_box(color = "yellow", width=150, height=10, x=90, y=-200, angle=90),
play.new_box(color = "yellow", width=200, height=10, x=10, y=-150),
play.new_box(color = "yellow", width=250, height=10, x=-150, y=-100, angle=90),
play.new_box(color = "yellow", width=200, height=10, x=0, y=-70),
play.new_box(color = "yellow", width=200, height=10, x=180, y=-200, angle=90),
play.new_box(color = "yellow", width=200, height=10, x=-100, y=-200),
play.new_box(color = "blue", width=100, height=10, x=200, y=-160),
play.new_box(color = "blue", width=200, height=10, x=-100, y=0),
play.new_box(color = "blue", width=100, height=10, x=200, y=0),
play.new_box(color = "blue", width=200, height=10, x=180, y=50, angle=90),
play.new_box(color = "blue", width=300, height=10, x=-250, y=-30, angle=90),
play.new_box(color = "blue", width=250, height=10, x=-250, y=-100),
play.new_box(color = "blue", width=250, height=10, x=250, y=-100, angle=90),
play.new_box(color = "red", width=250, height=10, x=-200, y=90),
play.new_box(color = "blue", width=150, height=10, x=-10, y=60, angle=90),
play.new_box(color = "blue", width=250, height=10, x=180, y=50),
play.new_box(color = "blue", width=250, height=10, x=-250, y=-100),
play.new_box(color = "red", width=250, height=10, x=180, y=150),
play.new_box(color = "red", width=250, height=10, x=-100, y=200, angle=90),
play.new_box(color = "blue", width=250, height=10, x=-0, y=200),]
coin= [play.new_circle(color="gold", radius=10, x=-200, y=-50, border_width=2, border_color="gray"),
play.new_circle(color="gold", radius=10, x=60, y=-200, border_width=2, border_color="gray"),
play.new_circle(color="gold", radius=10, x=150, y=-200, border_width=2, border_color="gray"),
play.new_circle(color="gold", radius=10, x=200, y=-120, border_width=2, border_color="gray"),
play.new_circle(color="gold", radius=10, x=200, y=-50, border_width=2, border_color="gray"),
play.new_circle(color="gold", radius=10, x=150, y=100, border_width=2, border_color="gray"),
play.new_circle(color="gold", radius=10, x=200, y=100, border_width=2, border_color="gray")]
@play.when_program_starts
def start():
ball.start_physics(x_speed=10, y_speed=10, bounciness=0.3)
for wall in walls:
wall.start_physics(can_move=False)
wall.color="gray"

@play.repeat_forever
def run():
ball.physics.x_speed = 0
if play.key_is_pressed("up", "w"):
ball.physics.y_speed=10
if play.key_is_pressed("left", "a", "ф"):
ball.physics.x_speed = -10
if play.key_is_pressed("right", "d", "в"):
ball.physics.x_speed = +10

if ball.is_touching(finish):
finish.words = "You are win"
finish.x = 0
finish.y = 0
finish.font_size = 60
for wall in walls:
wall.physics.can_move = True

play.start_program()​

stas289 stas289    2   04.06.2021 20:49    0

Другие вопросы по теме Информатика