import pygame import pymunk import sys def create_apple(space, pos): body = pymunk.Body(1, 100, body_type=pymunk.Body.DYNAMIC) body.position = pos shape = pymunk.Circle(body, 80) space.add(body, shape) return shape def draw_apples(apples): for apple in apples: pos_x, pos_y = apple.body.position apple_rect = apple_surface.get_rect(center=(int(pos_x), int(pos_y))) screen.blit(apple_surface, apple_rect) def static_ball(space): body = pymunk.Body(body_type=pymunk.Body.STATIC) body.position = (500, 500) shape = pymunk.Circle(body, 50) space.add(body, shape) return shape def draw_static_ball(balls): for ball in balls: pygame.draw.circle(screen, (0, 0, 0), (int(ball.body.position.x), int(ball.body.position.y)), 50) # Initialize Pygame pygame.init() screen = pygame.display.set_mode((800, 800)) clock = pygame.time.Clock() # Set up Pymunk space space = pymunk.Space() space.gravity = (0, 500) # Load image or fallback try: apple_surface = pygame.image.load("creedon.png").convert_alpha() except: apple_surface = pygame.Surface((160, 160), pygame.SRCALPHA) pygame.draw.circle(apple_surface, (255, 0, 0), (80, 80), 80) # Red placeholder apple # Game objects apples = [] balls = [static_ball(space)] # Main loop while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.MOUSEBUTTONDOWN: apples.append(create_apple(space, event.pos)) screen.fill((217, 217, 217)) draw_apples(apples) draw_static_ball(balls) space.step(1 / 50) pygame.display.update() clock.tick(120)