import pygame, sys, pymunk, random, time h = 0 mode = int(input("keys\n")) mode += 1 number = int(input("pattern\n")) pattern = "" while number > 0: pattern = str(number % mode) + pattern number = number // mode print(pattern) def create_apple(space, pos): body = pymunk.Body(1, 100, body_type = pymunk.Body.KINEMATIC) body.position = pos body.velocity = (0, 200) shape = pymunk.Circle(body, 65) # hitbox size, 65 is default space.add(body, shape) return shape def draw_apples(apples): for apple in apples: pos_x = int(apple.body.position.x) pos_y = int(apple.body.position.y) apple_surface = pygame.image.load('apple_red.png') apple_rect = apple_surface.get_rect(center = (pos_x, pos_y)) screen.blit(apple_surface, apple_rect) def static_ball(space, pos): body = pymunk.Body(body_type = pymunk.Body.STATIC) body.position = pos shape = pymunk.Circle(body, 50) space.add(body, shape) return shape def draw_static_ball(balls): for ball in balls: pos_x = int(ball.body.position.x) pos_y = int(ball.body.position.y) pygame.draw.circle(screen, (0, 0, 0), (pos_x, pos_y), 40) pygame.init() screen = pygame.display.set_mode((1600, 900)) clock = pygame.time.Clock() space = pymunk.Space() space.gravity = (0, 0) apples = [] balls = [] for j in range(mode-1): balls.append(static_ball(space, (j*150 - mode*75 + 900, 800))) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() screen.fill((217, 217, 217)) draw_apples(apples) draw_static_ball(balls) space.step(1/50) pygame.display.update() clock.tick(120) speed = 10 if h/speed < len(pattern): if h % speed == 0 and int(pattern[h // speed]) != 0: apples.append(create_apple(space, (int(pattern[h // speed]) * 150 - mode*75 + 750, 0))) h += 1